开发者社区> 问答> 正文

用Python3调用机器人返回param error

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 )





展开
收起
swow01 2017-05-27 15:57:15 3077 0
1 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
Python第五讲——关于爬虫如何做js逆向的思路 立即下载
Python第四讲——使用IPython/Jupyter Notebook与日志服务玩转超大规模数据分析与可视化 立即下载
Improving Python and Spark 立即下载