python3使用Http和urlli两种方式访问均返回param error,谁会解决帮帮忙看一下
代码
dd_html = 'https://oapi.dingtalk.com/robot/send?access_token=1689c53190aeaa556bf65ce2ba47d6f7582000ebca5bbeb785059a94fb507b8e'
#
[font='宋体']定义头部信息
dd_header
=
{
'Cache-Control'
:
'no-cache',
'Content-Type'
:
'application/json',
# 'Content-Type': 'application/json',
'User-Agent'
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
'postman-token'
:
'1689c53190aeaa556bf65ce2ba47d6f7582000ebca5bbeb785059a94fb507b8e'
}
#
data
dd_datad
=
{
#"access_token": "1689c53190aeaa556bf65ce2ba47d6f7582000ebca5bbeb785059a94fb507b8e",
"mgstype"
:
"text",
"text"
:
{
"content"
:
"hello bbb"
},
"at"
:
{
"atMobiles"
: dd_mobile,
"isAtAll"
:
False
}
}
dd_dataj
= bytes
(dd_dataj,
'utf8'
)
#
[font='宋体']请求
url
# dd_requests = urllib.request.Request(url=dd_html, data=dd_dataj, headers=dd_header, method='POST')
dd_requests
= urllib.request.Request
(dd_html, dd_dataj
)
dd_requests.add_header
(
'Content-Type',
'application/json'
)
#
[font='宋体']打开
url
dd_open
= urllib.request.urlopen
(url
=dd_requests, timeout
=20
)
#
[font='宋体']读取源码
dd_read
= dd_open.read
().decode
()
print
(dd_read
)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。