get_yn_cookies.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on 2024-09-22
  4. ---------
  5. @summary: 磐云 360
  6. ---------
  7. @author: Lzz
  8. """
  9. import requests
  10. import execjs
  11. import re
  12. def get_aw(tg1, tg2, tg3):
  13. ex_js = '''
  14. function gaw(tg1,tg2,tg3){
  15. var x08c924 = parseInt(tg1);
  16. x08c924 = x08c924 * parseInt(tg2);
  17. x08c924 = x08c924 + parseInt(tg3);
  18. x08c924 = (x08c924 * 0x3 + 0x7);
  19. if (x08c924 < 0x7b)
  20. x08c924 = x08c924 + 0x929;
  21. if (x08c924 > 0x929)
  22. x08c924 = Math["floor"](x08c924 / 0x7b);
  23. return x08c924
  24. }
  25. '''
  26. ctx = execjs.compile(ex_js)
  27. aw = ctx.call('gaw', tg1, tg2, tg3)
  28. return aw
  29. def get_ck(url=None, proxies=False):
  30. if not url:
  31. url = "http://www.yngp.com/page/supervision/supervisionList.html"
  32. session = requests.Session()
  33. session.proxies = proxies
  34. session.verify = False
  35. try:
  36. headers = {
  37. "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
  38. "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
  39. "Cache-Control": "no-cache",
  40. "Content-Type": "application/x-www-form-urlencoded",
  41. "Origin": "http://www.yngp.com",
  42. "Pragma": "no-cache",
  43. "Proxy-Connection": "keep-alive",
  44. "Referer": url,
  45. "Upgrade-Insecure-Requests": "1",
  46. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
  47. }
  48. res2 = session.get(url, headers=headers, timeout=30)
  49. torg_list = "".join(re.findall('\|function\|(.*?)version', res2.text))
  50. if torg_list:
  51. torg_list = torg_list.split('|')
  52. tg1 = torg_list[1]
  53. tg2 = torg_list[3]
  54. tg3 = torg_list[-2]
  55. aw = get_aw(tg1, tg2, tg3)
  56. data1 = {
  57. "answer": f"{aw}"
  58. }
  59. res = session.post(url, headers=headers, data=data1, timeout=30)
  60. urly = "http://www.yngp.com/api/common/otheruse.linklist.svc"
  61. respo = session.post(urly, headers=headers, timeout=30)
  62. if session.cookies.get_dict().get('JSESSIONID'):
  63. return session.cookies.get_dict()
  64. else:
  65. return {}
  66. except:
  67. return {}