checkinNew.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. File: checkin.py(GLaDOS签到)
  5. Author: GJBlack
  6. cron: 40 0 * * *
  7. new Env('GLaDOS签到');
  8. Update: 2023/8/2
  9. """
  10. import requests
  11. import json
  12. import os
  13. import sys
  14. import time
  15. # GlaDOS签到
  16. def checkin(cookie):
  17. checkin_url= "https://glados.rocks/api/user/checkin"
  18. state_url= "https://glados.rocks/api/user/status"
  19. referer = 'https://glados.rocks/console/checkin'
  20. origin = "https://glados.rocks"
  21. useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
  22. payload={
  23. 'token': 'glados.one'
  24. }
  25. try:
  26. checkin = requests.post(checkin_url,headers={
  27. 'cookie': cookie ,
  28. 'referer': referer,
  29. 'origin':origin,
  30. 'user-agent':useragent,
  31. 'content-type':'application/json;charset=UTF-8'},data=json.dumps(payload))
  32. state = requests.get(state_url,headers={
  33. 'cookie': cookie ,
  34. 'referer': referer,
  35. 'origin':origin,
  36. 'user-agent':useragent})
  37. except Exception as e:
  38. print(f"签到失败,请检查网络:{e}")
  39. return None, None, None
  40. try:
  41. mess = checkin.json()['message']
  42. mail = state.json()['data']['email']
  43. time = state.json()['data']['leftDays'].split('.')[0]
  44. except Exception as e:
  45. print(f"解析登录结果失败:{e}")
  46. return None, None, None
  47. return mess, time, mail
  48. # 执行签到任务
  49. def run_checkin():
  50. cookies = ['这里写cookie']
  51. contents = []
  52. for cookie in cookies:
  53. ret, remain, email = checkin(cookie)
  54. if not ret:
  55. continue
  56. content = f"签到时间:{time.strftime('%Y-%m-%d-%H_%M_%S',time.localtime(time.time()))}\n账号:{email}\n签到结果:{ret}\n剩余天数:{remain}\n"
  57. print(content)
  58. contents.append(content)
  59. contents_str = "".join(contents)
  60. return contents_str
  61. if __name__ == '__main__':
  62. title = "GlaDOS签到通知"
  63. contents = run_checkin()
  64. #print(contents)