Selaa lähdekoodia

add 看一看plus抓取规则

zhangyong 1 vuosi sitten
vanhempi
commit
87e9225833
1 muutettua tiedostoa jossa 7 lisäystä ja 1 poistoa
  1. 7 1
      kanyikan/kanyikan_recommend/kanyikan_recommend_plus.py

+ 7 - 1
kanyikan/kanyikan_recommend/kanyikan_recommend_plus.py

@@ -138,6 +138,8 @@ class KanyikanRecommend:
                             video_url = feeds[i]["videoInfo"]["videoCdnInfo"]["urlInfo"][0]["url"]
                         videoId = feeds[i].get("videoId", "")
                         videoId = "{}kyk_plus".format(videoId)
+                        playCount = int(feeds[i].get("playCount", 0))
+                        shared_cnt = int(feeds[i].get("shared_cnt", 0))
                         video_dict = {
                             "video_title": video_title,
                             "video_id": videoId,
@@ -160,7 +162,10 @@ class KanyikanRecommend:
                         for k, v in video_dict.items():
                             Common.logger(log_type, crawler).info(f"{k}:{v}")
                         Common.logging(log_type, crawler, env, f"video_dict:{video_dict}")
-
+                        video_percent = '%.2f' % (shared_cnt / playCount)
+                        if float(video_percent) <= 0.05:
+                            Common.logger(log_type, crawler).info(f"分享/播放<0.05:{video_percent}\n")
+                            Common.logging(log_type, crawler, env, f"分享/播放<0.05:{video_percent}\n")
                         if video_dict["video_id"] == "" or video_dict["video_title"] == "" or video_dict["video_url"] == "":
                             Common.logger(log_type, crawler).info("无效视频\n")
                             Common.logging(log_type, crawler, env, "无效视频\n")
@@ -178,6 +183,7 @@ class KanyikanRecommend:
                         elif cls.repeat_video(log_type, crawler, video_dict["video_id"], env) != 0:
                             Common.logger(log_type, crawler).info('视频已下载\n')
                             Common.logging(log_type, crawler, env, '视频已下载\n')
+
                         else:
                             video_dict["out_user_id"] = video_dict["user_id"]
                             video_dict["platform"] = crawler