|
| 1 | +# coding=utf-8 |
| 2 | +# author: pbbqdd |
| 3 | +# modify: wfion |
| 4 | +import http.cookiejar |
| 5 | +import json |
| 6 | +import os |
| 7 | +import time |
| 8 | +import urllib.request as urllib2 |
| 9 | + |
| 10 | + |
| 11 | +class Qiandao(): |
| 12 | + |
| 13 | + def __init__(self): |
| 14 | + self.timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime()) |
| 15 | + self.cookie = http.cookiejar.CookieJar() |
| 16 | + self.handler = urllib2.HTTPCookieProcessor(self.cookie) |
| 17 | + opener = urllib2.build_opener(self.handler) |
| 18 | + urllib2.install_opener(opener) |
| 19 | + |
| 20 | + def sign(self, url_add, user_phone): |
| 21 | + req2 = urllib2.Request("http://m.client.10010.com/mobileService/login.htm", |
| 22 | + url_add.encode('utf-8') + self.timestamp.encode('utf-8')) |
| 23 | + if urllib2.urlopen(req2).getcode() == 200: |
| 24 | + print('login success!') |
| 25 | + try: |
| 26 | + for item1 in self.cookie: |
| 27 | + if item1.name == 'a_token': |
| 28 | + a = item1.value |
| 29 | + except: |
| 30 | + print("cant get cookies") |
| 31 | + req3 = urllib2.Request("https://act.10010.com/SigninApp/signin/querySigninActivity.htm?token=" + a) |
| 32 | + if urllib2.urlopen(req3).getcode() == 200: |
| 33 | + print('querySigninActivity success!') |
| 34 | + req4 = urllib2.Request("https://act.10010.com/SigninApp/signin/daySign.do", "btnPouplePost".encode('utf-8')) |
| 35 | + if urllib2.urlopen(req4).getcode() == 200: |
| 36 | + print('daySign success!') |
| 37 | + req5 = urllib2.Request("https://act.10010.com/SigninApp/signin/goldTotal.do") |
| 38 | + print('phone: ' + user_phone + ' coin: ' + urllib2.urlopen(req5).read().decode('utf-8')) |
| 39 | + |
| 40 | + |
| 41 | +if __name__ == '__main__': |
| 42 | + path = os.path.dirname(os.path.abspath(__file__)) |
| 43 | + try: |
| 44 | + with open(path + '/config_unicom.json', 'r', encoding='utf-8') as f: |
| 45 | + dict_config = json.loads(f.read()) |
| 46 | + try: |
| 47 | + account_list = dict_config['accounts'] |
| 48 | + except KeyError as e: |
| 49 | + print('当前路径' + path + ' 配置文件错误,请检查config_unicom.json', e) |
| 50 | + i = 0 |
| 51 | + datalist = [] |
| 52 | + |
| 53 | + for item in account_list: |
| 54 | + i += 1 |
| 55 | + try: |
| 56 | + phone = item['phone'] |
| 57 | + url = item['url'] |
| 58 | + except KeyError as e: |
| 59 | + print('第%d个账户实例配置出错,跳过该账户' % i, e) |
| 60 | + continue |
| 61 | + |
| 62 | + user = Qiandao() |
| 63 | + user.sign(url, phone) |
| 64 | + |
| 65 | + except ValueError as e: |
| 66 | + print('出错了', e) |
| 67 | + except FileNotFoundError as e: |
| 68 | + print('当前路径' + path + ' 未找到config_unicom.json配置文件', e) |
| 69 | + except json.JSONDecodeError as e: |
| 70 | + print('config_unicom.json格式有误', e) |
0 commit comments