xiaoniangao_hour.py 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2023/3/15
  4. import datetime
  5. import json
  6. import os
  7. import random
  8. import shutil
  9. import sys
  10. import time
  11. import requests
  12. import urllib3
  13. sys.path.append(os.getcwd())
  14. from common.common import Common
  15. from common.feishu import Feishu
  16. from common.publish import Publish
  17. from common.db import MysqlHelper
  18. proxies = {"http": None, "https": None}
  19. class XiaoniangaoHour:
  20. platform = "小年糕"
  21. # # 配置微信
  22. # time.sleep(1)
  23. # wechat_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "dzcWHw")
  24. # hour_x_b3_traceid = wechat_sheet[2][1]
  25. # hour_x_token_id = wechat_sheet[3][1]
  26. # hour_referer = wechat_sheet[4][1]
  27. # hour_uid = wechat_sheet[5][1]
  28. # hour_token = wechat_sheet[6][1]
  29. # 生成 uid、token
  30. @classmethod
  31. def get_uid_token(cls):
  32. words = "abcdefghijklmnopqrstuvwxyz0123456789"
  33. uid = f"""{"".join(random.sample(words, 8))}-{"".join(random.sample(words, 4))}-{"".join(random.sample(words, 4))}-{"".join(random.sample(words, 4))}-{"".join(random.sample(words, 12))}"""
  34. token = "".join(random.sample(words, 32))
  35. uid_token_dict = {
  36. "uid": uid,
  37. "token": token
  38. }
  39. return uid_token_dict
  40. # 过滤敏感词
  41. @classmethod
  42. def filter_words(cls, log_type, crawler):
  43. try:
  44. while True:
  45. # 敏感词库列表
  46. word_list = []
  47. # 从云文档读取所有敏感词,添加到词库列表
  48. filter_sheet = Feishu.get_values_batch(log_type, "xiaoniangao", "DRAnZh")
  49. if filter_sheet is None:
  50. Common.logger(log_type, crawler).info(f"filter_sheet:{filter_sheet}")
  51. continue
  52. for i in filter_sheet:
  53. for j in i:
  54. # 过滤空的单元格内容
  55. if j is None:
  56. pass
  57. else:
  58. word_list.append(j)
  59. return word_list
  60. except Exception as e:
  61. Common.logger(log_type, crawler).error(f"filter_words:{e}\n")
  62. # 基础门槛规则
  63. @staticmethod
  64. def download_rule(video_dict):
  65. """
  66. 下载视频的基本规则
  67. :param video_dict: 视频信息,字典格式
  68. :return: 满足规则,返回 True;反之,返回 False
  69. """
  70. # 视频时长
  71. if int(float(video_dict["duration"])) >= 40:
  72. # 宽或高
  73. if int(video_dict["video_width"]) >= 0 or int(video_dict["video_height"]) >= 0:
  74. # 播放量
  75. if int(video_dict["play_cnt"]) >= 4000:
  76. # 点赞量
  77. if int(video_dict["like_cnt"]) >= 0:
  78. # 分享量
  79. if int(video_dict["share_cnt"]) >= 0:
  80. # 发布时间 <= 10 天
  81. if int(time.time()) - int(video_dict["publish_time_stamp"]) <= 3600*24*10:
  82. return True
  83. else:
  84. return False
  85. else:
  86. return False
  87. else:
  88. return False
  89. else:
  90. return False
  91. return False
  92. return False
  93. # 检查是否有今日的上升榜日期
  94. @classmethod
  95. def check_data(cls, log_type, crawler, date):
  96. while True:
  97. hour_sheet = Feishu.get_values_batch(log_type, crawler, "ba0da4")
  98. if hour_sheet is None:
  99. Common.logger(log_type, crawler).warning(f'小时级数据_feeds:{hour_sheet}\n')
  100. continue
  101. # 判断J1单元格的日期是否为今天
  102. if Feishu.get_range_value(log_type, crawler, "ba0da4", "L1:L1")[0] != date:
  103. # 插入3列 L1:N1,并写入日期和时间数据
  104. values = [[date], ["10:00", "15:00", "20:00"]]
  105. time.sleep(1)
  106. Feishu.insert_columns(log_type, crawler, "ba0da4", "COLUMNS", 11, 14)
  107. time.sleep(1)
  108. Feishu.update_values(log_type, crawler, "ba0da4", "L1:N2", values)
  109. time.sleep(1)
  110. Feishu.merge_cells(log_type, crawler, "ba0da4", "L1:N1")
  111. Common.logger(log_type, crawler).info("插入今天日期成功\n")
  112. return
  113. else:
  114. Common.logger(log_type, crawler).info("今日上升榜日期已存在\n")
  115. return
  116. # 获取表情及符号
  117. @classmethod
  118. def get_expression(cls):
  119. while True:
  120. expression_list = []
  121. char_list = []
  122. char_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "BhlbST")
  123. if char_sheet is None:
  124. continue
  125. for i in range(len(char_sheet)):
  126. if char_sheet[i][0] is not None:
  127. expression_list.append(char_sheet[i][0])
  128. if char_sheet[i][1] is not None:
  129. char_list.append(char_sheet[i][1])
  130. return expression_list, char_list
  131. @classmethod
  132. def repeat_video(cls, log_type, crawler, video_id, env, machine):
  133. sql = f""" select * from crawler_video where platform="小年糕" and out_video_id="{video_id}"; """
  134. repeat_video = MysqlHelper.get_values(log_type, crawler, sql, env, machine)
  135. return len(repeat_video)
  136. # 获取列表
  137. @classmethod
  138. def get_videoList(cls, log_type, crawler, env, machine):
  139. # try:
  140. uid_token_dict = cls.get_uid_token()
  141. url = "https://kapi.xiaoniangao.cn/trends/get_recommend_trends"
  142. headers = {
  143. # "x-b3-traceid": cls.hour_x_b3_traceid,
  144. "x-b3-traceid": '1c403a4aa72e3c',
  145. # "X-Token-Id": cls.hour_x_token_id,
  146. "X-Token-Id": 'ab619e96d801f1567388629260aa68ec-1202200806',
  147. # "uid": cls.hour_uid,
  148. "uid": uid_token_dict['uid'],
  149. "content-type": "application/json",
  150. "Accept-Encoding": "gzip,compress,br,deflate",
  151. "User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X)'
  152. ' AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 '
  153. 'MicroMessenger/8.0.20(0x18001432) NetType/WIFI Language/zh_CN',
  154. # "Referer": cls.hour_referer
  155. "Referer": 'https://servicewechat.com/wxd7911e4c177690e4/624/page-frame.html'
  156. }
  157. data = {
  158. "log_params": {
  159. "page": "discover_rec",
  160. "common": {
  161. "brand": "iPhone",
  162. "device": "iPhone 11",
  163. "os": "iOS 14.7.1",
  164. "weixinver": "8.0.20",
  165. "srcver": "2.24.2",
  166. "net": "wifi",
  167. "scene": 1089
  168. }
  169. },
  170. "qs": "imageMogr2/gravity/center/rotate/$/thumbnail/!750x500r/crop/750x500/interlace/1/format/jpg",
  171. "h_qs": "imageMogr2/gravity/center/rotate/$/thumbnail/!80x80r/crop/80x80/interlace/1/format/jpg",
  172. "share_width": 625,
  173. "share_height": 500,
  174. "ext": {
  175. "fmid": 0,
  176. "items": {}
  177. },
  178. "app": "xng",
  179. "rec_scene": "discover_rec",
  180. "log_common_params": {
  181. "e": [{
  182. "data": {
  183. "page": "discoverIndexPage",
  184. "topic": "recommend"
  185. },
  186. "ab": {}
  187. }],
  188. "ext": {
  189. "brand": "iPhone",
  190. "device": "iPhone 11",
  191. "os": "iOS 14.7.1",
  192. "weixinver": "8.0.20",
  193. "srcver": "2.24.3",
  194. "net": "wifi",
  195. "scene": "1089"
  196. },
  197. "pj": "1",
  198. "pf": "2",
  199. "session_id": "7bcce313-b57d-4305-8d14-6ebd9a1bad29"
  200. },
  201. "refresh": False,
  202. "token": uid_token_dict["token"],
  203. "uid": uid_token_dict["uid"],
  204. "proj": "ma",
  205. "wx_ver": "8.0.20",
  206. "code_ver": "3.62.0"
  207. }
  208. urllib3.disable_warnings()
  209. r = requests.post(url=url, headers=headers, json=data, proxies=proxies, verify=False)
  210. if 'data' not in r.text or r.status_code != 200:
  211. Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
  212. elif "data" not in r.json():
  213. Common.logger(log_type, crawler).warning(f"get_videoList:{r.json()}\n")
  214. elif "list" not in r.json()["data"]:
  215. Common.logger(log_type, crawler).warning(f"get_videoList:{r.json()['data']}\n")
  216. elif len(r.json()['data']['list']) == 0:
  217. Common.logger(log_type, crawler).warning(f"get_videoList:{r.json()['data']['list']}\n")
  218. else:
  219. # 视频列表数据
  220. feeds = r.json()["data"]["list"]
  221. for i in range(len(feeds)):
  222. # 标题,表情随机加在片头、片尾,或替代句子中间的标点符号
  223. if "title" in feeds[i]:
  224. befor_video_title = feeds[i]["title"].strip().replace("\n", "") \
  225. .replace("/", "").replace("\r", "").replace("#", "") \
  226. .replace(".", "。").replace("\\", "").replace("&NBSP", "") \
  227. .replace(":", "").replace("*", "").replace("?", "") \
  228. .replace("?", "").replace('"', "").replace("<", "") \
  229. .replace(">", "").replace("|", "").replace(" ", "").replace("#表情", "").replace("#符号", "")
  230. expression = cls.get_expression()
  231. expression_list = expression[0]
  232. char_list = expression[1]
  233. # 随机取一个表情
  234. expression = random.choice(expression_list)
  235. # 生成标题list[表情+title, title+表情]
  236. expression_title_list = [expression + befor_video_title, befor_video_title + expression]
  237. # 从标题list中随机取一个标题
  238. title_list1 = random.choice(expression_title_list)
  239. # 生成标题:原标题+符号
  240. title_list2 = befor_video_title + random.choice(char_list)
  241. # 表情和标题组合,与标题和符号组合,汇总成待使用的标题列表
  242. title_list4 = [title_list2, title_list1]
  243. # 最终标题
  244. video_title = random.choice(title_list4)
  245. else:
  246. video_title = 0
  247. # 视频 ID
  248. if "vid" in feeds[i]:
  249. video_id = feeds[i]["vid"]
  250. else:
  251. video_id = 0
  252. # 播放量
  253. if "play_pv" in feeds[i]:
  254. video_play_cnt = feeds[i]["play_pv"]
  255. else:
  256. video_play_cnt = 0
  257. # 点赞量
  258. if "favor" in feeds[i]:
  259. video_like_cnt = feeds[i]["favor"]["total"]
  260. else:
  261. video_like_cnt = 0
  262. # 评论数
  263. if "comment_count" in feeds[i]:
  264. video_comment_cnt = feeds[i]["comment_count"]
  265. else:
  266. video_comment_cnt = 0
  267. # 分享量
  268. if "share" in feeds[i]:
  269. video_share_cnt = feeds[i]["share"]
  270. else:
  271. video_share_cnt = 0
  272. # 时长
  273. if "du" in feeds[i]:
  274. video_duration = int(feeds[i]["du"] / 1000)
  275. else:
  276. video_duration = 0
  277. # 宽和高
  278. if "w" or "h" in feeds[i]:
  279. video_width = feeds[i]["w"]
  280. video_height = feeds[i]["h"]
  281. else:
  282. video_width = 0
  283. video_height = 0
  284. # 发布时间
  285. if "t" in feeds[i]:
  286. video_send_time = feeds[i]["t"]
  287. else:
  288. video_send_time = 0
  289. publish_time_stamp = int(int(video_send_time)/1000)
  290. publish_time_str = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(publish_time_stamp))
  291. # 用户名 / 头像
  292. if "user" in feeds[i]:
  293. user_name = feeds[i]["user"]["nick"].strip().replace("\n", "") \
  294. .replace("/", "").replace("快手", "").replace(" ", "") \
  295. .replace(" ", "").replace("&NBSP", "").replace("\r", "")
  296. head_url = feeds[i]["user"]["hurl"]
  297. else:
  298. user_name = 0
  299. head_url = 0
  300. # 用户 ID
  301. profile_id = feeds[i]["id"]
  302. # 用户 mid
  303. profile_mid = feeds[i]["user"]["mid"]
  304. # 视频封面
  305. if "url" in feeds[i]:
  306. cover_url = feeds[i]["url"]
  307. else:
  308. cover_url = 0
  309. # 视频播放地址
  310. if "v_url" in feeds[i]:
  311. video_url = feeds[i]["v_url"]
  312. else:
  313. video_url = 0
  314. video_dict = {
  315. "video_title": video_title,
  316. "video_id": video_id,
  317. "duration": video_duration,
  318. "play_cnt": video_play_cnt,
  319. "like_cnt": video_like_cnt,
  320. "comment_cnt": video_comment_cnt,
  321. "share_cnt": video_share_cnt,
  322. "user_name": user_name,
  323. "publish_time_stamp": publish_time_stamp,
  324. "publish_time_str": publish_time_str,
  325. "video_width": video_width,
  326. "video_height": video_height,
  327. "avatar_url": head_url,
  328. "profile_id": profile_id,
  329. "profile_mid": profile_mid,
  330. "cover_url": cover_url,
  331. "video_url": video_url,
  332. "session": f"xiaoniangao-hour-{int(time.time())}"
  333. }
  334. for k, v in video_dict.items():
  335. Common.logger(log_type, crawler).info(f"{k}:{v}")
  336. # 过滤无效视频
  337. if video_title == 0 or video_id == 0 or video_duration == 0 \
  338. or video_send_time == 0 or user_name == 0 or head_url == 0 \
  339. or cover_url == 0 or video_url == 0:
  340. Common.logger(log_type, crawler).warning("无效视频\n")
  341. # 抓取基础规则过滤
  342. elif cls.download_rule(video_dict) is False:
  343. Common.logger(log_type, crawler).info("不满足基础门槛规则\n")
  344. elif cls.repeat_video(log_type, crawler, video_dict['video_id'], env, machine) != 0:
  345. Common.logger(log_type, crawler).info('视频已下载\n')
  346. # 过滤敏感词
  347. elif any(str(word) if str(word) in video_title else False for word in cls.filter_words(log_type, crawler)) is True:
  348. Common.logger(log_type, crawler).info("视频已中过滤词\n")
  349. time.sleep(1)
  350. else:
  351. # 写入飞书小时级feeds工作表
  352. Feishu.insert_columns(log_type, crawler, "ba0da4", "ROWS", 2, 3)
  353. get_feeds_time = int(time.time())
  354. values = [[profile_id,
  355. profile_mid,
  356. video_id,
  357. video_title,
  358. user_name,
  359. video_duration,
  360. cover_url,
  361. video_url,
  362. publish_time_str,
  363. str(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(get_feeds_time))),
  364. video_play_cnt]]
  365. time.sleep(0.5)
  366. Feishu.update_values(log_type, crawler, "ba0da4", "A3:K3", values)
  367. Common.logger(log_type, crawler).info("视频添加至小时级数据_feeds成功\n")
  368. # except Exception as e:
  369. # Common.logger(log_type, crawler).error(f"get_videoList:{e}\n")
  370. @classmethod
  371. def download_video(cls, log_type, crawler, p_id, p_mid, v_title, v_id, strategy, oss_endpoint, env, machine):
  372. try:
  373. uid_token_dict = cls.get_uid_token()
  374. url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
  375. headers = {
  376. # "x-b3-traceid": cls.hour_x_b3_traceid,
  377. "x-b3-traceid": '1c403a4aa72e3c',
  378. # "X-Token-Id": cls.hour_x_token_id,
  379. "X-Token-Id": 'ab619e96d801f1567388629260aa68ec-1202200806',
  380. "uid": uid_token_dict['uid'],
  381. "content-type": "application/json",
  382. "Accept-Encoding": "gzip,compress,br,deflate",
  383. "User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X)'
  384. ' AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 '
  385. 'MicroMessenger/8.0.20(0x18001432) NetType/WIFI Language/zh_CN',
  386. # "Referer": cls.hour_referer
  387. "Referer": 'https://servicewechat.com/wxd7911e4c177690e4/624/page-frame.html'
  388. }
  389. data = {
  390. "play_src": "1",
  391. "profile_id": int(p_id),
  392. "profile_mid": int(p_mid),
  393. "qs": "imageMogr2/gravity/center/rotate/$/thumbnail/"
  394. "!400x400r/crop/400x400/interlace/1/format/jpg",
  395. "h_qs": "imageMogr2/gravity/center/rotate/$/thumbnail"
  396. "/!80x80r/crop/80x80/interlace/1/format/jpg",
  397. "share_width": 625,
  398. "share_height": 500,
  399. "no_comments": True,
  400. "no_follow": True,
  401. "vid": v_id,
  402. "hot_l1_comment": True,
  403. # "token": cls.hour_token,
  404. "token": uid_token_dict['token'],
  405. # "uid": cls.hour_uid,
  406. "uid": uid_token_dict['uid'],
  407. "proj": "ma",
  408. "wx_ver": "8.0.20",
  409. "code_ver": "3.62.0",
  410. "log_common_params": {
  411. "e": [{
  412. "data": {
  413. "page": "dynamicSharePage"
  414. }
  415. }],
  416. "ext": {
  417. "brand": "iPhone",
  418. "device": "iPhone 11",
  419. "os": "iOS 14.7.1",
  420. "weixinver": "8.0.20",
  421. "srcver": "2.24.3",
  422. "net": "wifi",
  423. "scene": "1089"
  424. },
  425. "pj": "1",
  426. "pf": "2",
  427. "session_id": "7bcce313-b57d-4305-8d14-6ebd9a1bad29"
  428. }
  429. }
  430. urllib3.disable_warnings()
  431. r = requests.post(headers=headers, url=url, json=data, proxies=proxies, verify=False)
  432. if r.status_code != 200 or 'data' not in r.text:
  433. Common.logger(log_type, crawler).warning(f"get_videoInfo:{r.text}\n")
  434. else:
  435. hour_play_cnt = r.json()["data"]["play_pv"]
  436. hour_cover_url = r.json()["data"]["url"]
  437. hour_video_url = r.json()["data"]["v_url"]
  438. hour_video_duration = r.json()["data"]["du"]
  439. hour_video_comment_cnt = r.json()["data"]["comment_count"]
  440. hour_video_like_cnt = r.json()["data"]["favor"]["total"]
  441. hour_video_share_cnt = r.json()["data"]["share"]
  442. hour_video_width = r.json()["data"]["w"]
  443. hour_video_height = r.json()["data"]["h"]
  444. hour_video_send_time = r.json()["data"]["t"]
  445. publish_time_stamp = int(int(hour_video_send_time)/1000)
  446. publish_time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(publish_time_stamp))
  447. hour_user_name = r.json()["data"]["user"]["nick"]
  448. hour_head_url = r.json()["data"]["user"]["hurl"]
  449. video_info_dict = {
  450. "video_id": v_id,
  451. "video_title": v_title,
  452. "duration": hour_video_duration,
  453. "play_cnt": hour_play_cnt,
  454. "like_cnt": hour_video_like_cnt,
  455. "comment_cnt": hour_video_comment_cnt,
  456. "share_cnt": hour_video_share_cnt,
  457. "user_name": hour_user_name,
  458. "publish_time_stamp": publish_time_stamp,
  459. "publish_time_str": publish_time_str,
  460. "video_width": hour_video_width,
  461. "video_height": hour_video_height,
  462. "avatar_url": hour_head_url,
  463. "profile_id": p_id,
  464. "profile_mid": p_mid,
  465. "cover_url": hour_cover_url,
  466. "video_url": hour_video_url,
  467. "session": f"xiaoniangao-hour-{int(time.time())}"
  468. }
  469. # 下载封面
  470. Common.download_method(log_type=log_type, crawler=crawler, text="cover", title=video_info_dict["video_title"], url=video_info_dict["cover_url"])
  471. # 下载视频
  472. Common.download_method(log_type=log_type, crawler=crawler, text="video", title=video_info_dict["video_title"], url=video_info_dict["video_url"])
  473. # 保存视频信息至 "./videos/{download_video_title}/info.txt"
  474. Common.save_video_info(log_type=log_type, crawler=crawler, video_dict=video_info_dict)
  475. # 上传视频
  476. Common.logger(log_type, crawler).info("开始上传视频...")
  477. our_video_id = Publish.upload_and_publish(log_type=log_type,
  478. crawler=crawler,
  479. strategy=strategy,
  480. our_uid="hour",
  481. env=env,
  482. oss_endpoint=oss_endpoint)
  483. if env == "dev":
  484. our_video_link = f"https://testadmin.piaoquantv.com/cms/post-detail/{our_video_id}/info"
  485. else:
  486. our_video_link = f"https://admin.piaoquantv.com/cms/post-detail/{our_video_id}/info"
  487. Common.logger(log_type, crawler).info("视频上传完成")
  488. if our_video_id is None:
  489. # 删除视频文件夹
  490. shutil.rmtree(f"./{crawler}/videos/{video_info_dict['video_title']}")
  491. return
  492. # 视频信息保存数据库
  493. rule_dict = {
  494. "duration": {"min": 40},
  495. "play_cnt": {"min": 4000},
  496. "publish_day": {"min": 10}
  497. }
  498. insert_sql = f""" insert into crawler_video(video_id,
  499. out_user_id,
  500. platform,
  501. strategy,
  502. out_video_id,
  503. video_title,
  504. cover_url,
  505. video_url,
  506. duration,
  507. publish_time,
  508. play_cnt,
  509. crawler_rule,
  510. width,
  511. height)
  512. values({our_video_id},
  513. "{video_info_dict['profile_id']}",
  514. "{cls.platform}",
  515. "小时榜爬虫策略",
  516. "{video_info_dict['video_id']}",
  517. "{video_info_dict['video_title']}",
  518. "{video_info_dict['cover_url']}",
  519. "{video_info_dict['video_url']}",
  520. {int(video_info_dict['duration'])},
  521. "{video_info_dict['publish_time_str']}",
  522. {int(video_info_dict['play_cnt'])},
  523. '{json.dumps(rule_dict)}',
  524. {int(video_info_dict['video_width'])},
  525. {int(video_info_dict['video_height'])}) """
  526. Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
  527. MysqlHelper.update_values(log_type, crawler, insert_sql, env, machine)
  528. Common.logger(log_type, crawler).info('视频信息插入数据库成功!')
  529. # 视频写入飞书
  530. Feishu.insert_columns(log_type, crawler, "yatRv2", "ROWS", 1, 2)
  531. # 视频ID工作表,首行写入数据
  532. upload_time = int(time.time())
  533. values = [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(upload_time)),
  534. "小时级上升榜",
  535. str(video_info_dict['video_id']),
  536. str(video_info_dict['video_title']),
  537. our_video_link,
  538. video_info_dict['play_cnt'],
  539. video_info_dict['comment_cnt'],
  540. video_info_dict['like_cnt'],
  541. video_info_dict['share_cnt'],
  542. video_info_dict['duration'],
  543. f"{video_info_dict['video_width']}*{video_info_dict['video_height']}",
  544. str(video_info_dict['publish_time_str'].replace("-", "/")),
  545. str(video_info_dict['user_name']),
  546. str(video_info_dict['profile_id']),
  547. str(video_info_dict['profile_mid']),
  548. str(video_info_dict['avatar_url']),
  549. str(video_info_dict['cover_url']),
  550. str(video_info_dict['video_url'])]]
  551. time.sleep(1)
  552. Feishu.update_values(log_type, crawler, "yatRv2", "F2:Z2", values)
  553. Common.logger(log_type, crawler).info('视频信息写入飞书成功\n')
  554. except Exception as e:
  555. Common.logger(log_type, crawler).error(f"download_video:{e}\n")
  556. # 更新小时榜数据
  557. @classmethod
  558. def update_videoList(cls, log_type, crawler, today, yesterday, before_yesterday):
  559. """
  560. 更新小时榜数据
  561. """
  562. try:
  563. update_hour_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "ba0da4")
  564. if len(update_hour_sheet) == 2:
  565. Common.logger(log_type, crawler).info("当前工作表无数据")
  566. else:
  567. for i in range(2, len(update_hour_sheet) + 1):
  568. Common.logger(log_type, crawler).info(f"更新第:{i+1}行视频信息")
  569. # 略过空行
  570. if update_hour_sheet[i][0] is None \
  571. or update_hour_sheet[i][1] is None or update_hour_sheet[i][2] is None:
  572. Common.logger(log_type, crawler).info("空行,略过")
  573. else:
  574. # 视频标题
  575. v_title = update_hour_sheet[i][3]
  576. Common.logger(log_type, crawler).info("video_title:{}", v_title)
  577. # 视频 ID
  578. v_id = update_hour_sheet[i][2]
  579. Common.logger(log_type, crawler).info("video_id:{}", v_id)
  580. # profile_id,用户 ID
  581. p_id = update_hour_sheet[i][0]
  582. Common.logger(log_type, crawler).info("profile_id:{}", p_id)
  583. # profile_mid
  584. p_mid = update_hour_sheet[i][1]
  585. Common.logger(log_type, crawler).info("profile_mid:{}", p_mid)
  586. # 抓取时的播放量
  587. v_play_cnt = update_hour_sheet[i][10]
  588. Common.logger(log_type, crawler).info("video_play_cnt:{}", v_play_cnt)
  589. # 抓取时间
  590. v_upload_time = update_hour_sheet[i][9]
  591. Common.logger(log_type, crawler).info("video_send_time:{}", v_upload_time)
  592. # 抓取时间的时间戳格式(秒为单位)
  593. v_time = int(time.mktime(time.strptime(v_upload_time, "%Y/%m/%d %H:%M:%S")))
  594. # 抓取时间:日期
  595. upload_data = v_upload_time.split(" ")[0]
  596. # 抓取时间:小时
  597. upload_hour = v_upload_time.split(" ")[-1].split(":")[0]
  598. uid_token_dict = cls.get_uid_token()
  599. url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
  600. headers = {
  601. # "x-b3-traceid": cls.hour_x_b3_traceid,
  602. "x-b3-traceid": '1c403a4aa72e3c',
  603. # "X-Token-Id": cls.hour_x_token_id,
  604. "X-Token-Id": 'ab619e96d801f1567388629260aa68ec-1202200806',
  605. # "uid": cls.hour_uid,
  606. "uid": uid_token_dict['uid'],
  607. "content-type": "application/json",
  608. "Accept-Encoding": "gzip,compress,br,deflate",
  609. "User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X)'
  610. ' AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 '
  611. 'MicroMessenger/8.0.20(0x18001432) NetType/WIFI Language/zh_CN',
  612. # "Referer": cls.hour_referer
  613. "Referer": 'https://servicewechat.com/wxd7911e4c177690e4/624/page-frame.html'
  614. }
  615. data = {
  616. "play_src": "1",
  617. "profile_id": int(p_id),
  618. "profile_mid": int(p_mid),
  619. "qs": "imageMogr2/gravity/center/rotate/$/thumbnail/"
  620. "!400x400r/crop/400x400/interlace/1/format/jpg",
  621. "h_qs": "imageMogr2/gravity/center/rotate/$/thumbnail"
  622. "/!80x80r/crop/80x80/interlace/1/format/jpg",
  623. "share_width": 625,
  624. "share_height": 500,
  625. "no_comments": True,
  626. "no_follow": True,
  627. "vid": v_id,
  628. "hot_l1_comment": True,
  629. # "token": cls.hour_token,
  630. # "uid": cls.hour_uid,
  631. "token": uid_token_dict['token'],
  632. "uid": uid_token_dict['uid'],
  633. "proj": "ma",
  634. "wx_ver": "8.0.20",
  635. "code_ver": "3.62.0",
  636. "log_common_params": {
  637. "e": [{
  638. "data": {
  639. "page": "dynamicSharePage"
  640. }
  641. }],
  642. "ext": {
  643. "brand": "iPhone",
  644. "device": "iPhone 11",
  645. "os": "iOS 14.7.1",
  646. "weixinver": "8.0.20",
  647. "srcver": "2.24.3",
  648. "net": "wifi",
  649. "scene": "1089"
  650. },
  651. "pj": "1",
  652. "pf": "2",
  653. "session_id": "7bcce313-b57d-4305-8d14-6ebd9a1bad29"
  654. }
  655. }
  656. try:
  657. urllib3.disable_warnings()
  658. r = requests.post(headers=headers, url=url, json=data, proxies=proxies, verify=False)
  659. hour_play_cnt = r.json()["data"]["play_pv"]
  660. Common.logger(log_type, crawler).info("视频详情,当前播放量:{}", hour_play_cnt)
  661. # 固定时间获取符合规则的视频,写入云文档:https://w42nne6hzg.feishu.cn/sheets/shtcngRPoDYAi24x52j2nDuHMih?sheet=ba0da4
  662. update_hour = datetime.datetime.now()
  663. if int(time.time()) - v_time >= 172800:
  664. Common.logger(log_type, crawler).info("抓取时间超过 2 天\n")
  665. return
  666. elif upload_data == today and update_hour.hour == 10 and int(upload_hour) <= 10:
  667. Common.logger(log_type, crawler).info("满足条件: 抓取日期为今天 and 当前时间:10点 and 抓取时间<=10点")
  668. # 当天 10:00 视频播放量
  669. ten_hour_play_cnt = hour_play_cnt
  670. Common.logger(log_type, crawler).info("当天 10:00 视频播放量:{}", ten_hour_play_cnt)
  671. # 10:00 的上升榜写入数据
  672. values = int(ten_hour_play_cnt) - int(v_play_cnt)
  673. time.sleep(1)
  674. Feishu.update_values(
  675. log_type, "xiaoniangao", "ba0da4",
  676. "L" + str(i + 1) + ":" + "L" + str(i + 1), [[values]])
  677. Common.logger(log_type, crawler).info(f"10:00数据更新成功:{values}\n")
  678. elif upload_data == today and update_hour.hour == 15 and int(upload_hour) <= 10:
  679. Common.logger(log_type, crawler).info("满足条件: 抓取日期为今天 and 当前时间:15点 and 抓取时间<=10点")
  680. # 当天 15:00 视频播放量
  681. fifteen_hour_play_cnt = hour_play_cnt
  682. Common.logger(log_type, crawler).info(f"当天 15:00 视频播放量:{fifteen_hour_play_cnt}")
  683. # 当天 10:00 上升的数据
  684. if update_hour_sheet[i][11] is None:
  685. ten_up_cnt = 0
  686. else:
  687. ten_up_cnt = update_hour_sheet[i][11]
  688. # 15:00 的上升榜写入数据
  689. values = int(fifteen_hour_play_cnt) - (int(v_play_cnt) + int(ten_up_cnt))
  690. time.sleep(1)
  691. Feishu.update_values(
  692. log_type, "xiaoniangao", "ba0da4",
  693. "M" + str(i + 1) + ":" + "M" + str(i + 1), [[values]])
  694. Common.logger(log_type, crawler).info("15:00数据更新成功:{}\n", values)
  695. elif upload_data == today and update_hour.hour == 15 and 10 < int(upload_hour) <= 15:
  696. Common.logger(log_type, crawler).info("满足条件: 抓取日期为今天 and 当前时间:15点 and 10<抓取时间<=15点")
  697. # 当天 15:00 视频播放量
  698. fifteen_hour_play_cnt = hour_play_cnt
  699. Common.logger(log_type, crawler).info("当天 15:00 视频播放量:{}", fifteen_hour_play_cnt)
  700. # 15:00 的上升榜写入数据
  701. values = int(fifteen_hour_play_cnt) - int(v_play_cnt)
  702. time.sleep(1)
  703. Feishu.update_values(
  704. log_type, "xiaoniangao", "ba0da4",
  705. "M" + str(i + 1) + ":" + "M" + str(i + 1), [[values]])
  706. Common.logger(log_type, crawler).info("15:00数据更新成功:{}\n", values)
  707. elif upload_data == today and update_hour.hour == 20 and int(upload_hour) <= 10:
  708. Common.logger(log_type, crawler).info("满足条件: 抓取日期为今天 and 当前时间:20点 and 抓取时间<=10点")
  709. # 当天 20:00 视频播放量
  710. twenty_hour_play_cnt = hour_play_cnt
  711. Common.logger(log_type, crawler).info("当天 20:00 视频播放量:{}", twenty_hour_play_cnt)
  712. # 当天 10:00 上升的数据
  713. if update_hour_sheet[i][11] is None:
  714. ten_up_cnt = 0
  715. else:
  716. ten_up_cnt = update_hour_sheet[i][11]
  717. # 当天 15:00 上升的数据
  718. if update_hour_sheet[i][12] is None:
  719. fifteen_up_cnt = 0
  720. else:
  721. fifteen_up_cnt = update_hour_sheet[i][12]
  722. # 20:00 的上升榜写入数据
  723. values = int(twenty_hour_play_cnt) - (
  724. int(v_play_cnt) + int(ten_up_cnt) + int(fifteen_up_cnt))
  725. time.sleep(1)
  726. Feishu.update_values(
  727. log_type, "xiaoniangao", "ba0da4",
  728. "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
  729. Common.logger(log_type, crawler).info("20:00数据更新成功:{}\n", values)
  730. elif upload_data == today and update_hour.hour == 20 and 10 < int(upload_hour) <= 15:
  731. Common.logger(log_type, crawler).info("满足条件: 抓取日期为今天 and 当前时间:20点 and 10<抓取时间<=15点")
  732. # 当天 20:00 视频播放量
  733. twenty_hour_play_cnt = hour_play_cnt
  734. Common.logger(log_type, crawler).info("当天 20:00 视频播放量:{}", twenty_hour_play_cnt)
  735. # 当天 15:00 上升的数据
  736. if update_hour_sheet[i][12] is None:
  737. fifteen_up_cnt = 0
  738. else:
  739. fifteen_up_cnt = update_hour_sheet[i][12]
  740. # 20:00 的上升榜写入数据
  741. values = int(twenty_hour_play_cnt) - (int(v_play_cnt) + int(fifteen_up_cnt))
  742. time.sleep(1)
  743. Feishu.update_values(
  744. log_type, "xiaoniangao", "ba0da4",
  745. "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
  746. Common.logger(log_type, crawler).info("20:00数据更新成功:{}\n", values)
  747. elif upload_data == today and update_hour.hour == 20 and 15 < int(upload_hour) <= 20:
  748. Common.logger(log_type, crawler).info("满足条件: 抓取日期为今天 and 当前时间:20点 and 15<抓取时间<=20点")
  749. # 当天 20:00 视频播放量
  750. twenty_hour_play_cnt = hour_play_cnt
  751. Common.logger(log_type, crawler).info("当天 20:00 视频播放量:{}", twenty_hour_play_cnt)
  752. # 20:00 的上升榜写入数据
  753. values = int(twenty_hour_play_cnt) - int(v_play_cnt)
  754. time.sleep(1)
  755. Feishu.update_values(
  756. log_type, "xiaoniangao", "ba0da4",
  757. "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
  758. Common.logger(log_type, crawler).info("20:00数据更新成功:{}\n", values)
  759. elif (upload_data == yesterday or upload_data == before_yesterday) \
  760. and update_hour.hour == 10:
  761. Common.logger(log_type, crawler).info("满足条件: 抓取时间小于今天 and 当前时间:10点")
  762. # 当天 10:00 视频播放量
  763. ten_hour_play_cnt = hour_play_cnt
  764. Common.logger(log_type, crawler).info("当天 10:00 视频播放量:{}", ten_hour_play_cnt)
  765. # 10:00 的上升榜写入数据
  766. values = int(ten_hour_play_cnt) - int(v_play_cnt)
  767. time.sleep(1)
  768. Feishu.update_values(
  769. log_type, "xiaoniangao", "ba0da4",
  770. "L" + str(i + 1) + ":" + "L" + str(i + 1), [[values]])
  771. Common.logger(log_type, crawler).info("10:00数据更新成功:{}\n", values)
  772. elif (upload_data == yesterday or upload_data == before_yesterday) \
  773. and update_hour.hour == 15:
  774. Common.logger(log_type, crawler).info("满足条件: 抓取时间小于今天 and 当前时间:15点")
  775. # 当天 15:00 视频播放量
  776. fifteen_hour_play_cnt = hour_play_cnt
  777. Common.logger(log_type, crawler).info("当天 15:00 视频播放量:{}", fifteen_hour_play_cnt)
  778. # 当天 10:00 上升的数据
  779. if update_hour_sheet[i][11] is None:
  780. ten_up_cnt = 0
  781. else:
  782. ten_up_cnt = update_hour_sheet[i][11]
  783. # 15:00 的上升榜写入数据
  784. values = int(fifteen_hour_play_cnt) - (int(v_play_cnt) + int(ten_up_cnt))
  785. time.sleep(1)
  786. Feishu.update_values(
  787. log_type, "xiaoniangao", "ba0da4",
  788. "M" + str(i + 1) + ":" + "M" + str(i + 1), [[values]])
  789. Common.logger(log_type, crawler).info("15:00数据更新成功:{}\n", values)
  790. elif (upload_data == yesterday or upload_data == before_yesterday) \
  791. and update_hour.hour == 20:
  792. Common.logger(log_type, crawler).info("满足条件: 抓取时间小于今天 and 当前时间:20点")
  793. # 当天 20:00 视频播放量
  794. twenty_hour_play_cnt = hour_play_cnt
  795. Common.logger(log_type, crawler).info("当天 20:00 视频播放量:{}", twenty_hour_play_cnt)
  796. # 当天 10:00 上升的数据
  797. if update_hour_sheet[i][11] is None:
  798. ten_up_cnt = 0
  799. else:
  800. ten_up_cnt = update_hour_sheet[i][11]
  801. # 当天 15:00 上升的数据
  802. if update_hour_sheet[i][12] is None:
  803. fifteen_up_cnt = 0
  804. else:
  805. fifteen_up_cnt = update_hour_sheet[i][12]
  806. # 20:00 的上升榜写入数据
  807. values = int(twenty_hour_play_cnt) - (
  808. int(v_play_cnt) + int(ten_up_cnt) + int(fifteen_up_cnt))
  809. time.sleep(1)
  810. Feishu.update_values(
  811. log_type, "xiaoniangao", "ba0da4",
  812. "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
  813. Common.logger(log_type, crawler).info("20:00数据更新成功:{}\n", values)
  814. except Exception as e:
  815. Common.logger(log_type, crawler).error("视频详情:{},异常:{}\n", v_title, e)
  816. except Exception as e:
  817. Common.logger(log_type, crawler).error("获取小时榜数据异常:{}\n", e)
  818. # 下载/上传
  819. @classmethod
  820. def download_publish(cls, log_type, crawler, strategy, oss_endpoint, env, machine):
  821. """
  822. 2.从云文档中下载符合规则的视频:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=ba0da4
  823. 2.1 当日 10:00 or 15:00 or 20:00 视频播放量上升 > 5000
  824. 2.2 当日 10:00 and 15:00 视频播放量上升 > 2000
  825. 2.3 当日 15:00 and 20:00 视频播放量上升 > 2000
  826. 2.4 昨日 20:00 and 今日 10:00 视频播放量上升 > 2000
  827. """
  828. while True:
  829. try:
  830. hour_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "ba0da4")
  831. if hour_sheet is None:
  832. Common.logger(log_type, crawler).warning(f"小时级数据_feeds:{hour_sheet}\n")
  833. continue
  834. if len(hour_sheet) == 2:
  835. Common.logger(log_type, crawler).info("小时级数据_feeds,没有数据\n")
  836. return
  837. for i in range(2, len(hour_sheet)):
  838. Common.logger(log_type, crawler).info(f"分析第:{i+1}行视频信息是否符合下载规则")
  839. # 略过空行
  840. if hour_sheet[i][0] is None or hour_sheet[i][1] is None or hour_sheet[i][2] is None:
  841. Common.logger(log_type, crawler).info("空行,略过")
  842. continue
  843. # 视频标题
  844. v_title = hour_sheet[i][3]
  845. # 视频 ID
  846. v_id = hour_sheet[i][2]
  847. # profile_id,用户 ID
  848. p_id = hour_sheet[i][0]
  849. # profile_mid
  850. p_mid = hour_sheet[i][1]
  851. # 抓取时间
  852. v_upload_time = hour_sheet[i][9]
  853. v_send_time = int(time.mktime(time.strptime(v_upload_time, "%Y/%m/%d %H:%M:%S")))
  854. # 播放量
  855. v_play_cnt = hour_sheet[i][10]
  856. # 今日 10:00 数据上升量
  857. if hour_sheet[i][11] is None:
  858. ten_cnt = 0
  859. else:
  860. ten_cnt = hour_sheet[i][11]
  861. # 今日 15:00 数据上升量
  862. if hour_sheet[i][12] is None:
  863. fifteen_cnt = 0
  864. else:
  865. fifteen_cnt = hour_sheet[i][12]
  866. # 今日 20:00 数据上升量
  867. if hour_sheet[i][13] is None:
  868. twenty_cnt = 0
  869. else:
  870. twenty_cnt = hour_sheet[i][13]
  871. # 昨日 20:00 数据上升量
  872. if hour_sheet[i][16] is None:
  873. yesterday_twenty_cnt = 0
  874. else:
  875. yesterday_twenty_cnt = hour_sheet[i][16]
  876. Common.logger(log_type, crawler).info(f"视频标题:{v_title}")
  877. Common.logger(log_type, crawler).info(f"10:00 / 15:00 / 20:00 上升量: {ten_cnt} / {fifteen_cnt} / {twenty_cnt}")
  878. if int(time.time()) - int(v_send_time) >= 3600*24*3:
  879. Common.logger(log_type, crawler).info("抓取时间超过 3 天")
  880. return
  881. elif cls.repeat_video(log_type, crawler, v_id, env, machine) != 0:
  882. Common.logger(log_type, crawler).info('视频已下载\n')
  883. # 播放量大于 50000,直接下载
  884. elif int(v_play_cnt) >= 50000:
  885. Common.logger(log_type, crawler).info(f"播放量:{v_play_cnt} >= 50000,满足下载规则,开始下载视频")
  886. cls.download_video(log_type=log_type, crawler=crawler, p_id=p_id, p_mid=p_mid, v_title=v_title, v_id=v_id,
  887. strategy=strategy, oss_endpoint=oss_endpoint, env=env, machine=machine)
  888. # 上升榜判断逻辑,任意时间段上升量>=5000,连续两个时间段上升量>=2000
  889. elif int(ten_cnt) >= 5000 or int(fifteen_cnt) >= 5000 or int(twenty_cnt) >= 5000:
  890. Common.logger(log_type, crawler).info(f"10:00 or 15:00 or 20:00 数据上升量:{ten_cnt} or {fifteen_cnt} or {twenty_cnt} >= 5000")
  891. Common.logger(log_type, crawler).info("满足下载规则,开始下载视频")
  892. cls.download_video(log_type=log_type, crawler=crawler, p_id=p_id, p_mid=p_mid, v_title=v_title, v_id=v_id,
  893. strategy=strategy, oss_endpoint=oss_endpoint, env=env, machine=machine)
  894. elif int(ten_cnt) >= 2000 and int(fifteen_cnt) >= 2000:
  895. Common.logger(log_type, crawler).info(f"10:00 and 15:00 数据上升量:{ten_cnt} and {fifteen_cnt} >= 2000")
  896. Common.logger(log_type, crawler).info("满足下载规则,开始下载视频")
  897. cls.download_video(log_type=log_type, crawler=crawler, p_id=p_id, p_mid=p_mid, v_title=v_title, v_id=v_id,
  898. strategy=strategy, oss_endpoint=oss_endpoint, env=env, machine=machine)
  899. elif int(fifteen_cnt) >= 2000 and int(twenty_cnt) >= 2000:
  900. Common.logger(log_type, crawler).info(f"15:00 and 20:00 数据上升量:{fifteen_cnt} and {twenty_cnt} >= 2000")
  901. Common.logger(log_type, crawler).info("满足下载规则,开始下载视频")
  902. cls.download_video(log_type=log_type, crawler=crawler, p_id=p_id, p_mid=p_mid, v_title=v_title, v_id=v_id,
  903. strategy=strategy, oss_endpoint=oss_endpoint, env=env, machine=machine)
  904. elif int(yesterday_twenty_cnt) >= 2000 and int(ten_cnt) >= 2000:
  905. Common.logger(log_type, crawler).info(f"昨日20:00 and 今日10:00 数据上升量:{yesterday_twenty_cnt} and {ten_cnt} >= 2000")
  906. Common.logger(log_type, crawler).info("满足下载规则,开始下载视频")
  907. cls.download_video(log_type=log_type, crawler=crawler, p_id=p_id, p_mid=p_mid, v_title=v_title, v_id=v_id,
  908. strategy=strategy, oss_endpoint=oss_endpoint, env=env, machine=machine)
  909. else:
  910. Common.logger(log_type, crawler).info("上升量不满足下载规则")
  911. except Exception as e:
  912. Common.logger(log_type, crawler).error(f"download_publish:{e}\n")
  913. if __name__ == "__main__":
  914. # print(XiaoniangaoHour.filter_words("hour", "xiaoniangao"))
  915. # print(XiaoniangaoHour.get_uid_token())
  916. pass