demo.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2022/6/13
  4. import json
  5. import time
  6. import requests
  7. from main.feishu_lib import Feishu
  8. class Demo:
  9. @classmethod
  10. def get_video_info(cls, session, vid):
  11. url = "https://search.weixin.qq.com/cgi-bin/recwxa/recwxagetonevideoinfo?"
  12. param = {
  13. "session": session,
  14. "vid": vid,
  15. "wxaVersion": "3.9.2",
  16. "channelid": "208201",
  17. "scene": "32",
  18. "subscene": "1089",
  19. "model": "iPhone 11<iPhone12,1>14.7.1",
  20. "clientVersion": "8.0.18",
  21. "sharesearchid": "447665862521758270",
  22. "sharesource": "-1"
  23. }
  24. r = requests.get(url=url, params=param)
  25. response = json.loads(r.content.decode("utf8"))
  26. data = response["data"]
  27. v_title = data["title"]
  28. v_play_cnt = data["played_cnt"]
  29. v_comment_cnt = data["comment_cnt"]
  30. v_liked_cnt = data["liked_cnt"]
  31. v_shared_cnt = data["shared_cnt"]
  32. v_duration = data["duration"]
  33. v_width = data["width"]
  34. v_height = data["height"]
  35. v_send_date = data["upload_time"]
  36. v_username = data["user_info"]["nickname"].strip().replace("\n", "")
  37. v_user_id = data["openid"]
  38. v_user_cover = data["user_info"]["headimg_url"]
  39. v_video_cover = data["cover_url"]
  40. v_url = data["play_info"]["items"][-1]["play_url"]
  41. print(f"v_title:{v_title}")
  42. print(f"v_play_cnt:{v_play_cnt}")
  43. print(f"v_liked_cnt:{v_liked_cnt}")
  44. print(f"v_comment_cnt:{v_comment_cnt}")
  45. print(f"v_shared_cnt:{v_shared_cnt}")
  46. print(f"v_duration:{v_duration}")
  47. print(f"v_url:{v_url}")
  48. @classmethod
  49. def strtime_to_int(cls):
  50. download_time = "2022/06/13 17:21:01"
  51. download_time = int(time.mktime(time.strptime(download_time, "%Y/%m/%d %H:%M:%S")))
  52. print(download_time)
  53. @classmethod
  54. def demo1(cls):
  55. a = 10
  56. b = 20
  57. lines = len(Feishu.get_values_batch("C8LQ1b"))
  58. for i in range(1, lines):
  59. print(f"i:{i}")
  60. if i == a or i == b:
  61. print(f"正在删除:{i+1}行")
  62. Feishu.dimension_range("C8LQ1b", "ROWS", i+1, i+1)
  63. lines = lines-1
  64. if __name__ == "__main__":
  65. demo = Demo()
  66. session = "LHacJPGEcMn7Cb0ocD_Z1BDyCkRbNjux4_HuHAwpydcHHdw9uwJl9pyiZgD__06uuDUwZ-_vqY5XQ_mS0XFz43xUYxwE_HsmxvluYfOVR5kXJmgjEVMlSDJ-R2IRr6ObHVZDaSLPV_i52pL0joEWP3FSHOZpXa72I9SPFUdQ1LRRGVvEhQBxMjuqvymnK5bv1HJwS_UoDIoue2nOrWmTCCAiR7YOUGnE8pwL0RLxsxSXU_fa3Ujgr9SbzFf3WhPo_QV92loTyXBTCJ8V8FsISqSKRlupG4n7osIyvEgtJEMS4Lt8K14Pc9i6X4e2EDUwoY66dOYbaoG5jaYgtdzKdYICRKnUK8jg_EAiSW7xzuorOLyoGDXlpL3AjVfivcys98Dg5b-BwTx7YhjUSbyVfDKrA5NFUY8cXJAJ2jWM6SSL91UNXVse7k4e8gMRGceC"
  67. videoid = "ugc_xnl1c7"
  68. demo.get_video_info(session, videoid)
  69. # demo.strtime_to_int()
  70. # demo.demo1()
  71. # Feishu.insert_columns("C8LQ1b", "ROWS", 1, 2)