| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- import base64
- import datetime
- import json
- import logging
- import os.path
- import time
- import requests
- import ddddocr
- # 配置日志
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
- # 配置文件路径
- CONFIG_FILE = "config.json"
- # 初始化配置
- def init_config():
- if not os.path.exists(CONFIG_FILE):
- with open(CONFIG_FILE, "w", encoding="utf-8") as f:
- json.dump({}, f)
- # 读取配置
- def load_config():
- with open(CONFIG_FILE, "r", encoding="utf-8") as f:
- return json.load(f)
- # 保存配置
- def save_config(config):
- with open(CONFIG_FILE, "w", encoding="utf-8") as f:
- json.dump(config, f, indent=4)
- # 获取版本号
- def get_version(config):
- if "version" not in config:
- # 这里可以添加获取版本号的逻辑
- config["version"] = "1.1.3"
- save_config(config)
- return config["version"]
- # 获取App ID
- def get_app_id(config):
- if "appid" not in config:
- response = requests.get(
- f"https://www.aeropres.in/chromeapi/dawn/v1/appid/getappid?app_v={get_version(config)}",
- proxies=config.get("proxy"),
- headers={
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},
- verify=False,
- timeout=15
- )
- if response.status_code != 200:
- raise Exception("获取appid失败")
- config["appid"] = response.json()["data"]["appid"]
- save_config(config)
- return config["appid"]
- # 获取Puzzle ID
- def get_puzzle_id(config):
- app_id = get_app_id(config)
- headers = {
- "Accept": "*/*",
- "Accept-Encoding": "gzip, deflate, br, zstd",
- "Accept-Language": "zh-CN,zh;q=0.9",
- "Origin": "chrome-extension://fpdkjdnhkakefebpekbdhillbhonfjjp",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
- "priority": "u=1, i",
- "sec-ch-ua": '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
- "sec-ch-ua-mobile": "?0",
- "sec-ch-ua-platform": '"Windows"',
- "sec-fetch-dest": "empty",
- "sec-fetch-mode": "cors",
- "sec-fetch-site": "cross-site",
- }
- response = requests.get(
- f"https://www.aeropres.in/chromeapi/dawn/v1/puzzle/get-puzzle?appid={app_id}",
- proxies=config.get("proxy"),
- headers=headers,
- verify=False,
- timeout=15
- )
- if response.status_code not in [200, 201]:
- raise Exception("获取puzzle_id失败")
- res_json = response.json()
- if not res_json.get('success', False):
- raise Exception("获取puzzle_id结果失败")
- return res_json["puzzle_id"]
- # 获取Puzzle Code
- def get_puzzle_code(config):
- puzzle_id = get_puzzle_id(config)
- headers = {
- "Accept": "*/*",
- "Accept-Encoding": "gzip, deflate, br, zstd",
- "Accept-Language": "zh-CN,zh;q=0.9",
- "Origin": "chrome-extension://fpdkjdnhkakefebpekbdhillbhonfjjp",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
- "priority": "u=1, i",
- "sec-ch-ua": '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
- "sec-ch-ua-mobile": "?0",
- "sec-ch-ua-platform": '"Windows"',
- "sec-fetch-dest": "empty",
- "sec-fetch-mode": "cors",
- "sec-fetch-site": "cross-site",
- }
- response = requests.get(
- f"https://www.aeropres.in/chromeapi/dawn/v1/puzzle/get-puzzle-image?puzzle_id={puzzle_id}&appid={get_app_id(config)}",
- proxies=config.get("proxy"),
- headers=headers,
- verify=False,
- timeout=15
- )
- if response.status_code != 200:
- raise Exception("获取puzzle_url失败")
- res_json = response.json()
- if not res_json.get('success', False):
- raise Exception("获取puzzle_url结果失败")
- imgBase64 = res_json["imgBase64"]
- data = base64.b64decode(imgBase64)
- return get_code_with_img(puzzle_id, img_data=data)
- # 获取验证码
- def get_code_with_img(puzzle_id, img_data):
- print(puzzle_id)
- with open(f'{str(int(time.time()))}.jpg', 'wb') as file:
- file.write(img_data)
- return False
- # 获取Token
- def get_token(config):
- if "token" not in config:
- retry_count = config.get('retry', 3)
- code = ""
- puzzle_id = ""
- while retry_count > 0:
- try:
- puzzle_id = get_puzzle_id(config)
- code = get_puzzle_code(config)
- break
- except Exception as e:
- logging.error(f"获取token失败,{e}")
- retry_count -= 1
- if not code or not puzzle_id:
- return False
- data = {
- "username": config.get("username", ""),
- "password": config.get("password", ""),
- "logindata": {"_v": {"version": get_version(config)},
- "datetime": datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")[:-3]},
- "puzzle_id": puzzle_id,
- "ans": code,
- "appid": get_app_id(config),
- }
- headers = {
- "Accept": "*/*",
- "Accept-Encoding": "gzip, deflate, br, zstd",
- "Accept-Language": "zh-CN,zh;q=0.9",
- "Origin": "chrome-extension://fpdkjdnhkakefebpekbdhillbhonfjjp",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
- "priority": "u=1, i",
- "sec-ch-ua": '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
- "sec-ch-ua-mobile": "?0",
- "sec-ch-ua-platform": '"Windows"',
- "sec-fetch-dest": "empty",
- "sec-fetch-mode": "cors",
- "sec-fetch-site": "cross-site",
- }
- retry_count = config.get('retry', 3)
- while retry_count > 0:
- try:
- response = requests.post(
- f"https://www.aeropres.in/chromeapi/dawn/v1/user/login/v2?appid={get_app_id(config)}",
- json=data,
- proxies=config.get("proxy"),
- verify=False,
- timeout=15,
- headers=headers
- )
- if response.status_code != 200:
- raise Exception("获取token失败")
- res_json = response.json()
- if not res_json.get('success', False):
- raise Exception("获取token结果失败")
- config["token"] = res_json["data"]["token"]
- save_config(config)
- break
- except Exception as e:
- logging.error(f"获取token失败,{e}")
- retry_count -= 1
- return config.get("token", "")
- # 获取积分
- def get_point(config):
- headers = {
- "Authorization": f"Bearer {config.get('token', '')}",
- "Content-Type": "application/json",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
- "sec-ch-ua": '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
- "sec-ch-ua-mobile": "?0",
- "sec-ch-ua-platform": '"Windows"',
- }
- response = requests.get(
- f"https://www.aeropres.in/api/atom/v1/userreferral/getpoint?appid={get_app_id(config)}",
- headers=headers,
- proxies=config.get("proxy"),
- verify=False,
- timeout=15
- )
- if response.status_code != 200:
- raise Exception(f"获取积分失败,{response.text}")
- if not response.json().get('success', False):
- raise Exception(f"获取积分失败,{response.json()}")
- # 保持活跃
- def keep_alive(config):
- headers = {
- "Authorization": f"Bearer {config.get('token', '')}",
- "Content-Type": "application/json",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
- }
- data = {
- "username": config.get("username", ""),
- "extensionid": "fpdkjdnhkakefebpekbdhillbhonfjjp",
- "numberoftabs": 0,
- "_v": get_version(config)
- }
- response = requests.post(
- f"https://www.aeropres.in/chromeapi/dawn/v1/userreward/keepalive?appid={get_app_id(config)}",
- json=data,
- headers=headers,
- proxies=config.get("proxy"),
- verify=False,
- timeout=15
- )
- if response.status_code != 200:
- raise Exception(f"保持活跃失败,{response.text}")
- if not response.json().get('success', False):
- raise Exception(f"保持活跃失败,{response.json()}")
- # 主函数
- def main():
- init_config()
- config = load_config()
- while True:
- token = get_token(config)
- if not token:
- time.sleep(60)
- del config['token']
- save_config(config)
- continue
- retry_count = 5
- while retry_count > 0:
- err = False
- try:
- get_point(config)
- except Exception as e:
- logging.error(f"获取积分失败,{e}")
- err = True
- try:
- keep_alive(config)
- except Exception as e:
- logging.error(f"保持活跃失败,{e}")
- err = True
- if not err:
- retry_count = 5
- else:
- retry_count -= 1
- if retry_count <= 0:
- break
- time.sleep(5 * 60)
- if __name__ == '__main__':
- main()
|