插件
[wechat_pyrobot 下载地址}(https://www.123pan.com/s/ihEKVv-XcWx.html)
代码
import os
import json
from wechat_pyrobot.msg_plugins import MonitorBiz
class MyMonitorBiz(MonitorBiz):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.name = os.path.basename(__file__)
# 注意当前所在目录是微信目录,而不是main.py所在目录,所以需要用__file__来定位
main_path = os.path.dirname(os.path.dirname(__file__))
self.save_path = os.path.join(main_path, "公众号监听数据.json")
def save_items(self, items):
# item是包含多个数据(字典)的列表
with open(self.save_path, 'a', encoding='utf-8') as f:
for item in items:
print(item)
f.write(json.dumps(item) + '\n')
from py_process_hooker import inject_python_and_monitor_dir
from wechat_pyrobot import get_on_startup
from plugins.biz import MyMonitorBiz
if __name__ == "__main__":
process_name = "WeChat.exe"
open_console = True
on_startup = get_on_startup(msg_plugins=[MyMonitorBiz])
inject_python_and_monitor_dir(process_name, __file__, open_console=open_console, on_startup=on_startup)