通过Python接口实现微信接收/发送消息、获取通讯录

作者:Sec-Labs | 发布时间:

WeChatStudy

StudyWechat,Support Version

  • [x] 3.7.6.44

The project is for study only, it is prohibited to use it for illegal purposes.

项目仅供学习参考,禁止用于非法用途。

项目地址

https://github.com/fjqisba/WeChatStudy

项目说明

WeChatDLL为核心DLL,在微信上搭建了一个http服务。

WeChatClient为客户端,通过http协议与微信通讯,使用前需要安装以下python库。

pip3 install pywin32
pip3 install numpy
pip3 install pefile

API接口说明

接收消息

resp = requests.get("http://127.0.0.1:5000/syncMsg")
print(resp.text)

接收朋友圈消息(不推荐频繁调用)

resp = requests.get("http://127.0.0.1:5000/syncSns")
print(resp.text)

获取通讯录列表

resp = requests.get("http://127.0.0.1:5000/getContactList")
print(resp.text)

获取通讯录

contactList = []
contactList.append("filehelper")
resp = requests.post("http://127.0.0.1:5000/getContactInfo",json = contactList)
print(resp.text)

发送文本消息

data = dict()
data["to_wxid"] = "filehelper"
data["msg"] = "hello wechat"
resp = requests.post("http://127.0.0.1:5000/sendTextMsg", json = data)
print(resp.text)

发送图片

data = dict()
data["to_wxid"] = "filehelper"
data["image_path"] = '''D:\\test.png'''
resp = requests.post("http://127.0.0.1:5000/sendImageMsg", json = data)
print(resp.text)

发送文件

data = dict()
data["to_wxid"] = "filehelper"
data["file_path"] = '''D:\\test.bin'''
resp = requests.post("http://127.0.0.1:5000/sendFile", json = data)
print(resp.text)

 

标签:工具分享, 思路分享, 学习笔记