demo.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2022/5/16
  4. import datetime
  5. import time
  6. from datetime import timedelta
  7. import requests
  8. import urllib3
  9. from main.feishu_lib import Feishu
  10. proxies = {"http": None, "https": None}
  11. class Demo:
  12. # 查询视频详情的各项数据
  13. @classmethod
  14. def video_detail_info(cls, user_id, user_mid, video_id):
  15. url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
  16. headers = {
  17. "x-b3-traceid": "bd267349bf41b",
  18. "X-Token-Id": "86f6d7cc2b2b6870004df5d16c82aaf3-1185665701",
  19. "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
  20. "content-type": "application/json",
  21. "Accept-Encoding": "gzip,compress,br,deflate",
  22. "User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X)'
  23. ' AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 '
  24. 'MicroMessenger/8.0.20(0x18001432) NetType/WIFI Language/zh_CN',
  25. "Referer": "https://servicewechat.com/wxd7911e4c177690e4/617/page-frame.html"
  26. }
  27. data = {
  28. "play_src": "1",
  29. "profile_id": int(user_id),
  30. "profile_mid": int(user_mid),
  31. "qs": "imageMogr2/gravity/center/rotate/$/thumbnail/"
  32. "!400x400r/crop/400x400/interlace/1/format/jpg",
  33. "h_qs": "imageMogr2/gravity/center/rotate/$/thumbnail"
  34. "/!80x80r/crop/80x80/interlace/1/format/jpg",
  35. "share_width": 625,
  36. "share_height": 500,
  37. "no_comments": True,
  38. "no_follow": True,
  39. "vid": video_id,
  40. "hot_l1_comment": True,
  41. "token": "90747742180aeb22c0fe3a3c6a38f3d9",
  42. "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
  43. "proj": "ma",
  44. "wx_ver": "8.0.20",
  45. "code_ver": "3.62.0",
  46. "log_common_params": {
  47. "e": [{
  48. "data": {
  49. "page": "dynamicSharePage"
  50. }
  51. }],
  52. "ext": {
  53. "brand": "iPhone",
  54. "device": "iPhone 11",
  55. "os": "iOS 14.7.1",
  56. "weixinver": "8.0.20",
  57. "srcver": "2.24.3",
  58. "net": "wifi",
  59. "scene": "1089"
  60. },
  61. "pj": "1",
  62. "pf": "2",
  63. "session_id": "7bcce313-b57d-4305-8d14-6ebd9a1bad29"
  64. }
  65. }
  66. try:
  67. urllib3.disable_warnings()
  68. r = requests.post(headers=headers, url=url, json=data, proxies=proxies, verify=False)
  69. video_title = r.json()["data"]["title"]
  70. video_id = r.json()["data"]["vid"]
  71. video_play_cnt = r.json()["data"]["play_pv"]
  72. video_duration = int(r.json()["data"]["du"])/1000
  73. video_url = r.json()["data"]["v_url"]
  74. video_send_time = r.json()["data"]["t"]
  75. print(r.text)
  76. print(f"video_title:{video_title}")
  77. print(f"video_id:{video_id}")
  78. print(f"video_play_cnt:{video_play_cnt}")
  79. print(f"video_duration:{video_duration}")
  80. print(f'video_send_time:{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(video_send_time)/1000))}')
  81. print(f"video_url:{video_url}")
  82. except Exception as e:
  83. print(e)
  84. # 时间
  85. @classmethod
  86. def times(cls):
  87. before_yesterday = (datetime.date.today() + timedelta(days=-2)).strftime("%Y/%m/%d %H:%M:%S")
  88. before_yesterday = time.strptime(before_yesterday, "%Y/%m/%d %H:%M:%S")
  89. before_yesterday = int(time.mktime(before_yesterday))
  90. print(before_yesterday)
  91. print(type(before_yesterday))
  92. # 微信号
  93. @classmethod
  94. def get_sheet(cls):
  95. hour_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "ba0da4")
  96. print(hour_sheet[2][8])
  97. if __name__ == "__main__":
  98. demo = Demo()
  99. # demo.video_detail_info("44838076", "116311065", "3941884615")
  100. # print("\n")
  101. # demo.video_detail_info("44767103", "116311065", "4167630382")
  102. # print("\n")
  103. # demo.video_detail_info("44264441", "329676836", "4505318929")
  104. # demo.times()
  105. # demo.video_detail_info("44615236", "460972177", "62a9965e000001609aa588ad")
  106. demo.get_sheet()