daily_3dos.py 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # -*- coding: utf-8 -*-
  2. import sys
  3. import os
  4. from httpx import Client
  5. from concurrent.futures import ThreadPoolExecutor, as_completed
  6. sys.path.append(os.path.join(os.path.abspath(__file__).split('auto')[0] + 'auto'))
  7. from utils.utils_send_gotify import *
  8. from utils.utils_daily_task_scheduler import *
  9. def daily_claim_3dos(email, password):
  10. # client = Client(proxy="http://127.0.0.1:7890")
  11. client = Client()
  12. login_url = "https://api.dashboard.3dos.io/api/auth/login"
  13. login_headers = {
  14. "Accept": "application/json, text/plain, */*",
  15. "Accept-Encoding": "gzip, deflate, br, zstd",
  16. "Accept-Language": "zh-CN,zh;q=0.9",
  17. "Content-Type": "application/json",
  18. "Origin": "https://dashboard.3dos.io",
  19. "Priority": "u=1, i",
  20. "Referer": "https://dashboard.3dos.io/",
  21. "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  22. "Sec-CH-UA-Mobile": "?0",
  23. "Sec-CH-UA-Platform": '"Windows"',
  24. "Sec-Fetch-Dest": "empty",
  25. "Sec-Fetch-Mode": "cors",
  26. "Sec-Fetch-Site": "same-site",
  27. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
  28. }
  29. login_payload = {
  30. "email": email,
  31. "password": password
  32. }
  33. try:
  34. login_response = client.post(login_url, json=login_payload, headers=login_headers)
  35. except Exception as e:
  36. print(f"登录请求失败:{e}")
  37. return False
  38. if login_response.status_code == 200:
  39. # print(f"{email}: 登录成功!")
  40. login_data = login_response.json()
  41. # print("登录响应内容:", login_data)
  42. data = login_data.get("data")
  43. token = data.get("access_token") or data.get("token")
  44. token_type = data.get("token_type")
  45. if not token or not token_type:
  46. print("登录响应中未找到 Token 或 Token 类型!")
  47. return False
  48. authorization_header = f"{token_type} {token}"
  49. else:
  50. print("登录失败!")
  51. print("登录响应状态码:", login_response.status_code)
  52. print("登录响应内容:", login_response.json())
  53. return False
  54. options_url = "https://api.dashboard.3dos.io/api/claim-reward"
  55. options_headers = {
  56. "Accept": "*/*",
  57. "Accept-Encoding": "gzip, deflate, br, zstd",
  58. "Accept-Language": "zh-CN,zh;q=0.9",
  59. "Access-Control-Request-Headers": "authorization,cache-control,content-type,expires,pragma",
  60. "Access-Control-Request-Method": "POST",
  61. "Origin": "https://dashboard.3dos.io",
  62. "Priority": "u=1, i",
  63. "Referer": "https://dashboard.3dos.io/",
  64. "Sec-Fetch-Dest": "empty",
  65. "Sec-Fetch-Mode": "cors",
  66. "Sec-Fetch-Site": "same-site",
  67. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
  68. }
  69. try:
  70. options_response = client.options(options_url, headers=options_headers)
  71. except Exception as e:
  72. print(f"OPTIONS 请求失败:{e}")
  73. return False
  74. # print("OPTIONS 请求响应状态码:", options_response.status_code)
  75. claim_url = "https://api.dashboard.3dos.io/api/claim-reward"
  76. claim_headers = {
  77. "Accept": "application/json, text/plain, */*",
  78. "Authorization": authorization_header,
  79. "Cache-Control": "no-cache",
  80. "Content-Type": "application/json",
  81. "Expires": "0",
  82. "Origin": "https://dashboard.3dos.io",
  83. "Pragma": "no-cache",
  84. "Priority": "u=1, i",
  85. "Referer": "https://dashboard.3dos.io/",
  86. "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  87. "Sec-CH-UA-Mobile": "?0",
  88. "Sec-CH-UA-Platform": '"Windows"',
  89. "Sec-Fetch-Dest": "empty",
  90. "Sec-Fetch-Mode": "cors",
  91. "Sec-Fetch-Site": "same-site",
  92. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
  93. }
  94. claim_payload = {
  95. "id": "daily-reward-api"
  96. }
  97. try:
  98. claim_response = client.post(claim_url, json=claim_payload, headers=claim_headers)
  99. except Exception as e:
  100. print(f"{email} claim-reward 请求失败:{e}")
  101. return False
  102. message = claim_response.json().get("message")
  103. if claim_response.status_code not in [200, 429]:
  104. print(f"{email} claim 报错: {message}, 状态码{claim_response.status_code}")
  105. return False
  106. result = f"{email}: {message}"
  107. return result
  108. def main():
  109. print("开始执行...")
  110. account_list = [
  111. "jack0210_@hotmail.com|||aaaAAA111!!!",
  112. "yujieccyj01@hotmail.com|||aaaAAA111!!!",
  113. "yujieccyj02@hotmail.com|||aaaAAA111!!!",
  114. "yujieccyj03@hotmail.com|||aaaAAA111!!!",
  115. "yujieccyj04@hotmail.com|||aaaAAA111!!!",
  116. "yujieccyj05@hotmail.com|||aaaaAA111!!!",
  117. "yujieccyj06@hotmail.com|||aaaAAA111!!!",
  118. "yujieccyj07@hotmail.com|||aaaAAA111!!!",
  119. "yujieccyj08@hotmail.com|||aaaAAA111!!!",
  120. "yujieccyj09@hotmail.com|||aaaAAA111!!!",
  121. "yujieccyj10@hotmail.com|||aaaAAA111!!!",
  122. ]
  123. send_str = ''
  124. with ThreadPoolExecutor(max_workers=len(account_list)) as executor:
  125. futures = []
  126. for account in account_list:
  127. email, password = account.split("|||")
  128. futures.append(executor.submit(daily_claim_3dos, email, password))
  129. for future in as_completed(futures):
  130. result = future.result()
  131. if result:
  132. send_str += result + '\n'
  133. print(result)
  134. if send_str:
  135. gotify_notifier = GotifyNotifier(title='3dos daily', message=send_str, token_name='CheckAndRemind')
  136. gotify_notifier.send_message()
  137. print(result)
  138. else:
  139. print("No news found.")
  140. if __name__ == "__main__":
  141. print('开始 3dos 每日签到')
  142. T = TaskScheduler(os.path.join(os.getcwd(), "daily_3dos.txt"))
  143. # 执行前读取执行时间, 判断是否到执行时间
  144. if not T.load_start_time():
  145. print('3dos 任务未到执行时间')
  146. exit(1)
  147. # 开始执行
  148. main()
  149. # 执行完成后, 将执行时间 + 24 小时写入文件
  150. T.save_start_time()