Python使用itcaht库实现微信自动收发消息功能
itchat库
- 模拟微信网页登录
- 通过pythoncode接受/发送微信消息
- 实现微信聊天机器人:调用聊天机器人api,将接收到的微信消息传给api,再将api返回的消息传给微信
展示如何使用itchat发送微信消息
#!pipinstallitchat importitchat
在当前文件夹下生成二维码图片,微信扫码即可登录网页版微信
itchat.auto_login()
GettinguuidofQRcode.
DownloadingQRcode.
PleasescantheQRcodetologin.
Pleasepressconfirmonyourphone.
Loadingthecontact,thismaytakealittlewhile.
Loginsuccessfullyas小白
通过微信名称查找接收消息的对象
users=itchat.search_friends(name="小白")#这里是给自己发送消息 user_name=users[0]["UserName"]
对象表示成这样的一个字符串
user_name
'@40f90812b2233588e8ebda1e8d8f01d48d32a384e31f0a96yaa4859a41123456'
toUserName指定接受消息的对象;每隔10s发送一次"helloworld",发送3次
importtime
foriinrange(3):
itchat.send("hello,world",toUserName=user_name)
time.sleep(10)
总结
到此这篇关于Python使用itcaht库实现微信自动收发消息的文章就介绍到这了,更多相关pythonitcaht库微信自动收发消息内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下