[python]摸鱼派自动签到
自动签到,花了几个小时,研究网站签到,图像处理用的别人的api,成了人民币玩家,经错半夜测试,已成功运行
废话不多说,直接上代码
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# @Time : 2021/10/27 18:01
4# @Author : Aen
5# @File : auto_login.py
6# @Software: PyCharm
7import base64
8import datetime
9import json
10import time
11import requests
12
13headers = {
14 'Connection': 'keep-alive',
15 'Accept': 'application/json, text/javascript, */*; q=0.01',
16 'Accept - Encoding': 'gzip, deflate',
17 'Accept - Language': 'zh - CN, zh;q = 0.9',
18 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
19 'Sec-Fetch-Site': 'same-origin',
20 'Sec-Fetch-Mode': 'cors',
21 'X-Requested-With': 'XMLHttpRequest',
22 'Sec-Fetch-Dest': 'empty',
23 'Referer': 'https://pwl.icu/',
24 'Cookie': 'cookie'
25}
26
27
28def base64_api(uname, pwd, img, typeid):
29 with open(img, 'rb') as f:
30 base64_data = base64.b64encode(f.read())
31 b64 = base64_data.decode()
32 data = {"username": uname, "password": pwd, "typeid": typeid, "image": b64}
33 result = json.loads(requests.post("http://api.ttshitu.com/predict", json=data).text)
34 if result['success']:
35 return result["data"]["result"]
36 else:
37 return result["message"]
38 return ""
39
40
41def auto_get_grade():
42 # img_path = "/Users/aen/Desktop/captcha.png"
43 # result = base64_api(uname='***', pwd='***', img=img_path, typeid=16)
44 # print(result)
45 session = requests.Session()
46 url1 = 'https://pwl.icu/'
47 url2 = 'https://pwl.icu/activity/daily-checkin-api/'
48 img_path = "okk.png"
49 download_url_tmp = 'https://pwl.icu/captcha?'
50 pic_time = int(round(time.time() * 1000))
51 download_url = download_url_tmp + str(pic_time)
52 print('pic downloading')
53 content_file = requests.get(url=download_url, headers=headers).content
54 print(download_url)
55 file_name = 'okk.png'
56 with open(file_name, 'wb') as fp:
57 fp.write(content_file)
58 print(file_name, 'download successful')
59 result = base64_api(uname='aeneag', pwd='Aen221909', img=img_path, typeid=16)
60 url3 = url2 + str(result)
61 print(url3)
62 response = session.get(url=url3, headers=headers)
63 print(response.text)
64 back_json = json.loads(response.text)
65 back_number = back_json['sum']
66 return back_number
67
68
69if __name__ == "__main__":
70 count = 0
71 while count < 4:
72 time.sleep(2)
73 res = auto_get_grade()
74 count = count + 1
75 if res == -1:
76 print('已经签到了')
77 with open('auto_login.log', 'a') as fp:
78 fp.write(str(datetime.datetime.now()) + ' successful \n')
79 break
80 if count == 4:
81 with open('auto_login.log', 'a') as fp:
82 fp.write(str(datetime.datetime.now()) + ' failed \n')
83
84 # if auto_get_grade() == -1:
85 # print('已经签到了')
86 # with open('auto_login.log', 'a') as fp:
87 # fp.write(str(datetime.datetime.now()) + ' successful \n')
88
吾心信其可行,
则移山填海之难,
终有成功之日!
——孙文
则移山填海之难,
终有成功之日!
——孙文
评论
0 评论