基于Python实现签到脚本过程解析
人气:0无聊刷日剧,看到签到断了好久,简单写了个脚本,通过模拟抓包的方式实现
1、先登录到字幕组网站获取token
2、用获取到的token登录到人人活动页面获取cookie
3、用获取到的cookie进行签到
import requests import json import time def main(): # 登录,获取用户信息 info = json.loads(get_token()) uid,token = info['data']['uid'],info['data']['token'] # 登录到活动中心,获取cookie cookies = get_huodong(uid,token) # 签到 while True: qiandao(cookies) time.sleep(10800) def qiandao(cookies): headers["Cookie"] = 'PHPSESSID={}'.format(cookies) info_url = "http://h5.rrhuodong.com/index.php?g=api/mission&m=index&a=user_info" info = json.loads(get(info_url).text)['data'] print("称昵:{}\n等级:{}\n人人钻:{}\n".format(info['nickname'],info['main_group_name'],info['point'])) qiandao_login_url = "http://h5.rrhuodong.com/index.php?g=api/mission&m=clock&a=store&id=2" print("签到信息:{}".format(json.loads(get(qiandao_login_url).text)['info'])) def get_huodong(uid,token): huodong_login_url = "http://h5.rrhuodong.com/index.php?g=api/mission&m=index&a=login&uid={}&token={}".format(uid,token) return requests.utils.dict_from_cookiejar(get(huodong_login_url).cookies)['PHPSESSID'] def get_token(): token_login_url = "http://a.zmzapi.com/index.php?g=api/public&m=v2&accesskey={}&client=2&a=login&account={}&password={}".format(accesskey,username,passwd) return get(token_login_url).text def get(url): content = requests.get(url.format(username,passwd), headers=headers, verify=False, allow_redirects=False) return content if __name__ == '__main__': # 浏览器头部 headers = { "User-Agent":"Mozilla/5.0 (Linux; U; Android 9; zh-cn; MI 6 Build/9.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/5.0 Mobile Safari/533.1" } # 账号、密码、accesskey需要自己抓包 username = '账号' passwd = '密码' accesskey="xxx" main()
您可能感兴趣的文章:
加载全部内容