daily_3dos.py 6.3 KB

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