main.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # -*- coding: utf-8 -*-
  2. import time
  3. import os
  4. import json
  5. import httpx
  6. class DuDog:
  7. def __init__(self, cookies_list):
  8. self.cookies_list = cookies_list
  9. def roll(self):
  10. url = "https://www.magicnewton.com/portal/api/userQuests"
  11. for cookies in self.cookies_list:
  12. headers = {
  13. "accept": "*/*",
  14. "accept-encoding": "gzip, deflate, br, zstd",
  15. "accept-language": "zh-CN,zh;q=0.9",
  16. "content-type": "application/json",
  17. "cookie": cookies,
  18. "origin": "https://www.magicnewton.com",
  19. "priority": "u=1, i",
  20. "referer": "https://www.magicnewton.com/portal/rewards",
  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-origin",
  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. payload = {"questId": "f56c760b-2186-40cb-9cbc-3af4a3dc20e2", "metadata": {"action": "ROLL"}}
  30. for times in range(6):
  31. try:
  32. response = httpx.post(url, headers=headers, json=payload)
  33. print(response.json())
  34. if response.json().get('message') == 'Quest already completed':
  35. print('Is Done!')
  36. break
  37. except Exception as e:
  38. print(str(e))
  39. time.sleep(3)
  40. if __name__ == '__main__':
  41. config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.txt")
  42. try:
  43. with open(config_path, "r", encoding="utf-8") as file:
  44. cookies_list = file.readlines()
  45. except Exception as e:
  46. print(f"读取配置失败:{e}")
  47. exit(1)
  48. D = DuDog(cookies_list)
  49. D.roll()