2022/11/10更新: 删库了,具体情况未知
发现一个三方库:ntchat,可以实现对微信的操作,有微信版本限制(WeChatSetup3.6.0.18)。
官方介绍:ntchat-GitHub
- 基于pc微信的api接口, 类似itchat项目
- 支持收发文本、群@、名片、图片、文件、视频、链接卡片等
- 支持好友和群管理
向传输助手发送信息
# -*- coding: utf-8 -*-
import sys
import ntchat
wechat = ntchat.WeChat()
# 打开pc微信, smart: 是否管理已经登录的微信
wechat.open(smart=True)
# 等待登录
wechat.wait_login()
# 向文件助手发送一条消息
wechat.send_text(to_wxid="filehelper", content="hello, filehelper")
try:
while True:
pass
except KeyboardInterrupt:
ntchat.exit_()
sys.exit()
获取联系人和群列表
# -*- coding: utf-8 -*-
import sys
import ntchat
wechat = ntchat.WeChat()
# 打开pc微信, smart: 是否管理已经登录的微信
wechat.open(smart=True)
# 等待登录
wechat.wait_login()
# 获取联系人列表并输出
contacts = wechat.get_contacts()
print("联系人列表: ")
print(contacts)
rooms = wechat.get_rooms()
print("群列表: ")
print(rooms)
try:
while True:
pass
except KeyboardInterrupt:
ntchat.exit_()
sys.exit()
更多推荐