daily_3dos.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # -*- coding: utf-8 -*-
  2. import os
  3. from httpx import Client
  4. from concurrent.futures import ThreadPoolExecutor, as_completed
  5. def daily_claim_3dos(email, password):
  6. client = Client(proxies="http://127.0.0.1:7890")
  7. login_url = "https://api.dashboard.3dos.io/api/auth/login"
  8. login_headers = {
  9. "Accept": "application/json, text/plain, */*",
  10. "Accept-Encoding": "gzip, deflate, br, zstd",
  11. "Accept-Language": "zh-CN,zh;q=0.9",
  12. "Content-Type": "application/json",
  13. "Origin": "https://dashboard.3dos.io",
  14. "Priority": "u=1, i",
  15. "Referer": "https://dashboard.3dos.io/",
  16. "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  17. "Sec-CH-UA-Mobile": "?0",
  18. "Sec-CH-UA-Platform": '"Windows"',
  19. "Sec-Fetch-Dest": "empty",
  20. "Sec-Fetch-Mode": "cors",
  21. "Sec-Fetch-Site": "same-site",
  22. "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"
  23. }
  24. login_payload = {
  25. "email": email,
  26. "password": password
  27. }
  28. try:
  29. login_response = client.post(login_url, json=login_payload, headers=login_headers)
  30. except Exception as e:
  31. print(f"登录请求失败:{e}")
  32. return False
  33. if login_response.status_code == 200:
  34. # print(f"{email}: 登录成功!")
  35. login_data = login_response.json()
  36. # print("登录响应内容:", login_data)
  37. data = login_data.get("data")
  38. token = data.get("access_token") or data.get("token")
  39. token_type = data.get("token_type")
  40. if not token or not token_type:
  41. print("登录响应中未找到 Token 或 Token 类型!")
  42. return False
  43. authorization_header = f"{token_type} {token}"
  44. else:
  45. print("登录失败!")
  46. print("登录响应状态码:", login_response.status_code)
  47. print("登录响应内容:", login_response.json())
  48. return False
  49. options_url = "https://api.dashboard.3dos.io/api/claim-reward"
  50. options_headers = {
  51. "Accept": "*/*",
  52. "Accept-Encoding": "gzip, deflate, br, zstd",
  53. "Accept-Language": "zh-CN,zh;q=0.9",
  54. "Access-Control-Request-Headers": "authorization,cache-control,content-type,expires,pragma",
  55. "Access-Control-Request-Method": "POST",
  56. "Origin": "https://dashboard.3dos.io",
  57. "Priority": "u=1, i",
  58. "Referer": "https://dashboard.3dos.io/",
  59. "Sec-Fetch-Dest": "empty",
  60. "Sec-Fetch-Mode": "cors",
  61. "Sec-Fetch-Site": "same-site",
  62. "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"
  63. }
  64. try:
  65. options_response = client.options(options_url, headers=options_headers)
  66. except Exception as e:
  67. print(f"OPTIONS 请求失败:{e}")
  68. return False
  69. # print("OPTIONS 请求响应状态码:", options_response.status_code)
  70. claim_url = "https://api.dashboard.3dos.io/api/claim-reward"
  71. claim_headers = {
  72. "Accept": "application/json, text/plain, */*",
  73. "Authorization": authorization_header,
  74. "Cache-Control": "no-cache",
  75. "Content-Type": "application/json",
  76. "Expires": "0",
  77. "Origin": "https://dashboard.3dos.io",
  78. "Pragma": "no-cache",
  79. "Priority": "u=1, i",
  80. "Referer": "https://dashboard.3dos.io/",
  81. "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  82. "Sec-CH-UA-Mobile": "?0",
  83. "Sec-CH-UA-Platform": '"Windows"',
  84. "Sec-Fetch-Dest": "empty",
  85. "Sec-Fetch-Mode": "cors",
  86. "Sec-Fetch-Site": "same-site",
  87. "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"
  88. }
  89. claim_payload = {
  90. "id": "daily-reward-api"
  91. }
  92. try:
  93. claim_response = client.post(claim_url, json=claim_payload, headers=claim_headers)
  94. except Exception as e:
  95. print(f"{email} claim-reward 请求失败:{e}")
  96. return False
  97. message = claim_response.json().get("message")
  98. if claim_response.status_code not in [200, 429]:
  99. print(f"{email} claim 报错: {message}, 状态码{claim_response.status_code}")
  100. return False
  101. result = f"{email}: {message}"
  102. return result
  103. def main():
  104. print("开始执行...")
  105. config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "account.txt")
  106. try:
  107. with open(config_path, "r", encoding="utf-8") as file:
  108. account_list = [line.strip() for line in file.readlines()]
  109. except Exception as e:
  110. print(f"读取配置失败:{e}")
  111. return
  112. with ThreadPoolExecutor(max_workers=len(account_list)) as executor:
  113. futures = []
  114. for account in account_list:
  115. email, password = account.split("|||")
  116. futures.append(executor.submit(daily_claim_3dos, email, password))
  117. for future in as_completed(futures):
  118. result = future.result()
  119. if result:
  120. print(result)
  121. if __name__ == "__main__":
  122. main()