一般来说分三种:
* 给公众号发送特定文字
* 普通的网页点击
* 授权的网页点击
我这里给出前两种的解决方案。
普通的网页点击:
1. 建议通过浏览器或者Wireshark分析消息的交互。
2. 之后通过requests模拟。
由于没有具体的网址,我没有办法给出具体的代码。
给公众号发送特定的问题:
1. 建议使用Python的微信API(pip install itchat)
2. 由于没有提供Python版本,我这里给出兼容的解决方案
#coding=utf8
import threading
import itchat
SIGN_IN_MP_DICT = {
u'学校微信公众号': u'学校签到口令',
u'公司微信公众号': u'公司签到口令', }
def get_day(timeGap):
return int(time.strftime('%y%m%d', time.localtime(time.time() + timeGap)))
NEXT_SIGN_DATE = get_day(60*60*24)
def sign_in_thread():
''' 签到线程
如果尚未到需要签到的日期,则继续循环
如果到了需要签到的日期,则完成两个公众号的签到,并更新日期
'''
while 1:
if get_day <NEXT_SIGN_DATE:
time.sleep(30)
else:
for k, v in SIGN_IN_MP_DICT.items():
itchat.send(msg=v,
toUserName=itchat.search_mps(name=k)[0]['UserName'])
NEXT_SIGN_DATE = get_day(60*60*24)
itchat.auto_login(True)
# 测试是否存在特定公众号
for mpName in SIGN_IN_MP_DICT.keys():
mpList = itchat.search_mps(name=mpName)
if len(mpList) != 1:
print(u'没有检测到公众号“%s”,请检查名称')
break
else:
signInThread = threading.Thread(target=sign_in_thread)
signInThread.setDaemon(True)
signInThread.start()
itchat.run()
很简单 用httpwatch类的抓包软件分析登陆的时候提交了那些参数,然后用Python的urllib包模拟http登陆就ok了,需要注意的是cookie问题,可以自己组装也可以使用Python的cookiejar。