python:3.8
模块:itchat
import itchat
itchat.auto_login(hotReload=True)
报错:
█
Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
Your wechat account may be LIMITED to log in WEB wechat, error info:
<error><ret>1203</ret><message>为了你的帐号安全,此微信号不能登录网页微信。你可以使用Windows微信或Mac微信在电脑端登录。Windows微信下载地址:https://pc.weixin.qq.com Mac微信下载地址:https://mac.weixin.qq.com</message></error>
>>>
应该是这个功能被微信禁止了,但没关系,我要的主要还是python本地的聊天机器人,所以跳过这一步
注册成功!说是新用户可以有每日免费数量
url="http://www.tuling123.com/openapi/api"
key="720b8495c39f40ac92284c5d6b3d1dd7"
msg="你好漂亮"
userid="100000"
data={
'key':key,
'info':msg,
'userid':userid
}
repson=requests.post(url,data=data).json()
print(repson.get("text"))
报错:NameError: name ‘requests’ is not defined
之前解决过这种问题,不太记得了,那就再来一遍!
尝试添加import requests
测试成功!那改成自己的key试试
改成自己的key后
回复:请按规定的要求进行加密
只能去看看文档了:
https://www.kancloud.cn/turing/www-tuling123-com/718218
找了半天,也没找到userid,问题没找到解决方案,暂时还是用原作者的key和id了
说点什么:你好
亲爱的,当天请求次数已用完。
说点什么:
{
"reqType":0,
"perception": {
"inputText": {
"text": "附近的酒店"
},
"inputImage": {
"url": "imageUrl"
},
"selfInfo": {
"location": {
"city": "北京",
"province": "北京",
"street": "信息路"
}
}
},
"userInfo": {
"apiKey": "",
"userId": ""
}
}
结果还是没找到,尝试看看在百度有没有吧
看到这里有个青云客:
http://api.qingyunke.com/
试一下:
结果:
requests.post('http://api.qingyunke.com/api.php?key=free&appid=0&msg=你好')
这个不报错
但用这种方式就报错了:
url="http://api.qingyunke.com/api.php"
key="free"
appid=0
msg="你好"
data={
'key':key,
'msg':msg,
'appid':appid
}
repson=requests.post(url,data).json()
先了解一下requests.post的原理吧
url_json = 'http://httpbin.org/post'
data_json = json.dumps({'key1':'value1','key2':'value2'}) #dumps:将python对象解码为json数据
r_json = requests.post(url_json,data_json)
print(r_json)
print(r_json.text)
print(r_json.content)
测试了还是不行
repson=requests.post(url+'key=free&appid=0&msg='+str).json()
用这个方式虽然不好看,但有效,有空了解下post吧!
回头,就完成聊天机器人和语音播放的融合吧!