可应用场景
多个群之间消息转发 微信群限制(500人)
客服机器人
社交与乐趣
自动打卡签到 日历提醒等
信息推广(新闻,产品,广告等)
监控警报
不支持功能
支付相关 - 红包、转账、收款 等都不支持
在群聊中@他人 - 是的,Web 微信中被人@后也不会提醒
发送名片 - 但可以通过 send_raw_msg() 转发
发送分享链接 - 也无法转发
发送语音消息
朋友圈相关
无法删除好友及公众号取消关注
风险及缺陷
存在一定概率被限制登录的可能性主要表现为无法登陆 Web 微信 (但不影响手机等其他平台)。
新注册微信号直接无法登陆 Web 微信
后续存在网页版微信有关停的风险
模块特色
发送文本、图片、视频、文件
通过关键词或用户属性搜索 好友、群聊、群成员等
获取好友/群成员的昵称、备注、性别、地区等信息
加好友,建群,邀请入群,移出群
简单上手
# 导入模块
fromwxpyimport
# 初始化机器人,扫码登陆
bot=Bot()
# 搜索名称含有 "游否" 的男性深圳好友
my_friend=bot.friends().search('游否',sex=MALE,city="深圳")[]
# 发送文本给好友
my_friend.send('Hello WeChat!')
# 发送图片
my_friend.send_image('my_picture.jpg')
# 搜索名称含有 "游否" 的男性深圳好友
my_friend=bot.friends().search('游否',sex=MALE,city="深圳")[]
# 发送文本给好友
my_friend.send('Hello WeChat!')
# 发送图片
my_friend.send_image('my_picture.jpg')
# 打印来自其他好友、群聊和公众号的消息
@bot.register()
defprint_others(msg):
print(msg)
# 回复 my_friend 的消息 (优先匹配后注册的函数!)
@bot.register(my_friend)defreply_my_friend(msg):
return'received:{}({})'.format(msg.text,msg.type)
# 自动接受新的好友请求
@bot.register(msg_types=FRIENDS)
defauto_accept_friends(msg):
# 接受好友请求new_friend=msg.card.accept()# 向新的好友发送消息
new_friend.send('哈哈,我自动接受了你的好友请求')
# 进入 Python 命令行、让程序保持运行
embed()
# 或者仅仅堵塞线程
# bot.join()
本文
介绍pywx的一些使用场景、不支持功能以及风险及缺陷,
领取专属 10元无门槛券
私享最新 技术干货