标签:好友 需要 aik 微信 json ble load usr 函数
前言之前写过一遍,pyhton结合图灵机器人自动回复,之前51cto是使用网页签到,但是已经失效了,微信签到的原理和之前的机器人差不多的,不过是使用了python的itchat模块,结合定时功能,自动签到。
python3
pip install itchat
pip install apscheduler
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author:Aiker Zhao
@file:sign_51cto.py
@time:下午12:06
"""
import itchat
import json
from apscheduler.schedulers.blocking import BlockingScheduler
itchat.auto_login(enableCmdQR=0, hotReload=True) # windows下使用enableCmdQR=0,linux命令行使用enableCmdQR=2
# 获取好友列表,调用此方法后可得到好友列表
my_mps = itchat.get_mps()
# friends = itchat.get_friends()
# 我们可以使用json库将好友列表转换成json格式
# print(json.dumps(friends))
# print(json.dumps(my_mps))
‘‘‘
# 暂时不用旧的函数
def job():
mps = itchat.search_mps(name=u‘51CTO‘)[0]
mps.send(u‘签到‘)
mps.send(u‘下载豆‘)
‘‘‘
def qiandao():
info_51cto = itchat.search_mps(‘51CTO‘)
if info_51cto:
username_51cto = info_51cto[0].get(‘UserName‘)
itchat.send(u‘签到‘, username_51cto)
itchat.send(u‘下载豆‘, username_51cto)
#qiandao()
def job_heartbeat():
info_51cto = itchat.search_mps(name=u‘51CTO‘)[0]
print(‘1‘)
sched = BlockingScheduler()
#sched = BlockingScheduler(timezone="UTC") # 如果报timezone不一致的错误,需要指定timezone
# sched.add_job(job, ‘interval‘, hours=24)
sched.add_job(qiandao, ‘cron‘, hour=16, minute=19, second=22)
sched.add_job(job_heartbeat, ‘interval‘, minutes=1)
sched.start()
def job():
u51cto = itchat.search_mps(name=u‘51CTO‘)
if u51cto:
mps = u51cto[0]
mps.send(u‘签到‘)
mps.send(u‘下载豆‘)
def qiandao():
info_51cto = itchat.search_mps(‘51CTO‘)
if info_51cto:
username_51cto = info_51cto[0].get(‘UserName‘)
itchat.send(u‘签到‘, username_51cto)
itchat.send(u‘下载豆‘, username_51cto)
心得:可以在云主机上后台运行,扫码登录即可
标签:好友 需要 aik 微信 json ble load usr 函数
原文地址:https://blog.51cto.com/m51cto/2377276