Python 爬取朋友圈最新方法!!
首先,需要添加指定的微信号,并且给这个微信号查看自己朋友圈的权限;
然后,等待几个小时;
最后,得到一个链接,里面用相册模板显示了自己的朋友圈内容;
import psutil
import pywinauto
from pywinauto.application import Application
psutil 用于获取微信电脑版的进程信息;
pywinauto 用于自动化控制微信电脑版
PID = 0
for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=['pid', 'name'])
except psutil.NoSuchProcess:
pass
else:
if 'WeChat.exe' == pinfo['name']:
PID = pinfo['pid']
app = Application(backend='uia').connect(process=PID)
win = app['微信']
pyq_btn = win.child_window(title="朋友圈", control_type="Button")
cords = pyq_btn.rectangle()
pywinauto.mouse.click(button='left', coords=(cords.left + 10, cords.top + 10))
print(pyq_win.dump_tree())
评论