main.py 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # -*- coding: utf-8 -*-
  2. import time
  3. import os
  4. import json
  5. import httpx
  6. class AgntTask:
  7. def __init__(self, cookies_list):
  8. self.cookies_list = cookies_list
  9. def daily_task(self):
  10. for cookies in self.cookies_list:
  11. url = "https://hub-api.agnthub.ai/api/daily-rewards/claim"
  12. headers = {
  13. "accept": "application/json, text/plain, */*",
  14. "accept-encoding": "gzip, deflate, br, zstd",
  15. "accept-language": "zh-CN,zh;q=0.9",
  16. "content-length": "0",
  17. "cookie": cookies,
  18. "origin": "https://quests.agnthub.ai",
  19. "priority": "u=1, i",
  20. "referer": "https://quests.agnthub.ai/",
  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. try:
  30. response = httpx.post(url, headers=headers)
  31. print(response.json())
  32. except Exception as e:
  33. print(str(e))
  34. def upload_task(self):
  35. for cookies in self.cookies_list:
  36. url = "https://hub-api.agnthub.ai/api/tasks/make-ai-laugh/34ecad1e-94df-48ba-b5f4-242fdd9d6546"
  37. headers = {
  38. "accept": "application/json, text/plain, */*",
  39. "accept-encoding": "gzip, deflate, br, zstd",
  40. "accept-language": "zh-CN,zh;q=0.9",
  41. "content-length": "0",
  42. "cookie": cookies,
  43. "origin": "https://quests.agnthub.ai",
  44. "priority": "u=1, i",
  45. "referer": "https://quests.agnthub.ai/",
  46. "sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  47. "sec-ch-ua-mobile": "?0",
  48. "sec-ch-ua-platform": '"Windows"',
  49. "sec-fetch-dest": "empty",
  50. "sec-fetch-mode": "cors",
  51. "sec-fetch-site": "same-site",
  52. "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"
  53. }
  54. try:
  55. response = httpx.post(url, headers=headers)
  56. print(response.json())
  57. except Exception as e:
  58. print(str(e))
  59. def tasks(self):
  60. tasks_list = [
  61. "6813de78-f821-4a84-8e8c-3aa89c15b2aa",
  62. "fce2e806-a6c7-4de2-abc2-260d13bcfb2f",
  63. "0bcb7d19-7c63-4933-96b0-00141ce54dbe",
  64. "2f3241c5-29a0-4f47-acf3-9370baf94e74",
  65. "d2b35062-40c1-48b8-bca5-c48779ccc66d",
  66. "ab2fd158-b894-47bc-aadb-645259b46cc0",
  67. "3861cd8e-5393-4285-b6ee-29a5ee301ee5",
  68. "1a75844a-a108-4fbd-bfc3-c7476b26b73d",
  69. "217e2f67-c110-4ef7-a636-8ac0623df3e8",
  70. "49c1db40-8ecf-4454-af0a-fcc81b222135",
  71. "2e6ff98c-132b-4886-8f38-6c89d1a7b02a",
  72. "9fc278e8-4045-4130-9f52-6ce3b713318c",
  73. "4f913da3-58b6-4636-a2c2-912fb01c73d4",
  74. "6216f4e1-eafb-4442-a5d4-5b1830f89655",
  75. "ebbba0a4-96d9-4fa4-85f9-6fb07fbc282a",
  76. "5172f361-d28e-4aa2-a3ba-2adfe5057539",
  77. "f81146e9-9ef9-4979-b0a0-437ea5c3e1bb",
  78. "22301ec3-3a75-4758-a886-ab768312ffe5",
  79. "6debaef3-844e-40f3-be6d-d99a6fd9f2a1",
  80. "932d0c29-22ad-4be5-92b4-fc3a2e13aaed",
  81. "05027b13-88a3-42a4-992a-0ce2a53068d4",
  82. "9e0addfa-51fd-4f3b-a6f2-8dbe301265aa",
  83. "4a42ba64-7822-469c-8899-bc07b5dd5d69",
  84. "516d941e-b006-4744-a190-6c3207750854",
  85. "bf9e7362-5eed-4110-bbe3-1289722a36b3",
  86. "7eed7668-e71a-42ed-98ac-a0ded8bc0296",
  87. "2cac41ba-36dd-4389-91b6-f8ee840083db",
  88. "6f888d49-2b59-4ba9-a7be-199dceff45ab"
  89. ]
  90. for cookies in cookies_list:
  91. for tasks in tasks_list:
  92. url = "https://hub-api.agnthub.ai/api/tasks/start/" + tasks
  93. headers = {
  94. "Accept": "application/json, text/plain, */*",
  95. "Accept-Encoding": "gzip, deflate, br, zstd",
  96. "Accept-Language": "zh-CN,zh;q=0.9",
  97. "Content-Length": "0",
  98. "Cookie": cookies,
  99. "Origin": "https://quests.agnthub.ai",
  100. "Priority": "u=1, i",
  101. "Referer": "https://quests.agnthub.ai/",
  102. "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  103. "Sec-CH-UA-Mobile": "?0",
  104. "Sec-CH-UA-Platform": '"Windows"',
  105. "Sec-Fetch-Dest": "empty",
  106. "Sec-Fetch-Mode": "cors",
  107. "Sec-Fetch-Site": "same-site",
  108. "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"
  109. }
  110. for retry in range(1, 4):
  111. try:
  112. response = httpx.post(url, headers=headers)
  113. if response.status_code == 201:
  114. print("请求成功!")
  115. print(response.json())
  116. break
  117. else:
  118. print(f"请求失败,状态码:{response.status_code}")
  119. print(response.text)
  120. except Exception as e:
  121. print(f"出现错误:{e}\n重试...")
  122. time.sleep(0.5)
  123. if __name__ == '__main__':
  124. config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.json")
  125. try:
  126. with open(config_path, "r", encoding="utf-8") as file:
  127. config_data = json.load(file)
  128. except Exception as e:
  129. print(f"读取配置失败:{e}")
  130. exit(1)
  131. cookies_list = config_data.get("cookies", [])
  132. A = AgntTask(cookies_list)
  133. A.daily_task()
  134. A.upload_task()
  135. A.tasks()