gzh_header.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. def header(func, token_dict):
  2. if func == "parse":
  3. headers = {
  4. "accept": "*/*",
  5. "accept-encoding": "gzip, deflate, br",
  6. "accept-language": "zh-CN,zh;q=0.9",
  7. "referer": "https://mp.weixin.qq.com/cgi-bin/appmsg?"
  8. "t=media/appmsg_edit_v2&action=edit&isNew=1"
  9. "&type=77&createType=5&token=" + str(token_dict['token']) +"&lang=zh_CN",
  10. "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
  11. "sec-ch-ua-mobile": "?0",
  12. "sec-ch-ua-platform": '"Windows"',
  13. "sec-fetch-dest": "empty",
  14. "sec-fetch-mode": "cors",
  15. "sec-fetch-site": "same-origin",
  16. "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
  17. " (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
  18. "x-requested-with": "XMLHttpRequest",
  19. "cookie": token_dict['cookie'],
  20. }
  21. return headers
  22. if func == "parse_video":
  23. parse_video_headers = {
  24. "accept": "*/*",
  25. "accept-encoding": "gzip, deflate, br",
  26. "accept-language": "zh-CN,zh;q=0.9",
  27. "referer": "https://mp.weixin.qq.com/cgi-bin/appmsg?"
  28. "t=media/appmsg_edit_v2&action=edit&isNew=1"
  29. "&type=77&createType=5&token="
  30. + str(token_dict["token"])
  31. + "&lang=zh_CN",
  32. "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
  33. "sec-ch-ua-mobile": "?0",
  34. "sec-ch-ua-platform": '"Windows"',
  35. "sec-fetch-dest": "empty",
  36. "sec-fetch-mode": "cors",
  37. "sec-fetch-site": "same-origin",
  38. "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
  39. " (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
  40. "x-requested-with": "XMLHttpRequest",
  41. "cookie": token_dict["cookie"],
  42. }
  43. return parse_video_headers
  44. def params(func, token_dict):
  45. if func == "parse":
  46. parse_params = {
  47. "action": "search_biz",
  48. "begin": "0",
  49. "count": "5",
  50. "query": "",
  51. "token": token_dict['token'],
  52. "lang": "zh_CN",
  53. "f": "json",
  54. "ajax": "1",
  55. }
  56. return parse_params
  57. if func == "parse_video":
  58. parse_video_params = {
  59. "action": "list_ex",
  60. "begin": "",
  61. "count": "5",
  62. "fakeid": "",
  63. "type": "9",
  64. "query": "",
  65. "token": str(token_dict["token"]),
  66. "lang": "zh_CN",
  67. "f": "json",
  68. "ajax": "1",
  69. }
  70. return parse_video_params