Explorar el Código

zhonglaonianyule

罗俊辉 hace 1 año
padre
commit
d3b89aed3e

+ 6 - 0
zhonglaonianyule/zhonglaonianyule_main/run_zlnyljkys_recommend.py

@@ -3,6 +3,7 @@
 # @Time: 2023/10/10
 import argparse
 import time
+import random
 
 from mq_http_sdk.mq_client import *
 from mq_http_sdk.mq_consumer import *
@@ -98,12 +99,17 @@ def main(log_type, crawler, topic_name, group_id, env):
                 Common.logging(
                     log_type, crawler, env, f'开始抓取:{task_dict["taskName"]}\n'
                 )
+                our_uid_list = []
+                for user in user_list:
+                    our_uid_list.append(user["uid"])
+                our_uid = random.choice(our_uid_list)
                 ZL = ZLNYLScheduling(
                     log_type=log_type,
                     crawler=crawler,
                     category=3615,
                     rule_dict=rule_dict,
                     env=env,
+                    our_uid=our_uid
                 )
                 for i in range(100):
                     if ZL.download_count >= int(rule_dict.get("videos_cnt", {}).get("min", 10)):

+ 3 - 2
zhonglaonianyule/zhonglaonianyule_recommend/zhonglaonianyule_recommend_scheduling.py

@@ -44,13 +44,14 @@ def clean_title(strings):
 
 
 class ZLNYLScheduling:
-    def __init__(self, log_type, crawler, category, rule_dict, env):
+    def __init__(self, log_type, crawler, category, rule_dict, env, our_uid):
         self.platform = "中老年娱乐"
         self.log_type = log_type
         self.crawler = crawler
         self.category = category
         self.rule_dict = rule_dict
         self.env = env
+        self.our_uid = our_uid
         self.mq = MQ(topic_name="topic_crawler_etl_" + self.env)
         self.download_count = 0
 
@@ -175,7 +176,7 @@ class ZLNYLScheduling:
                         video_dict["width"] = video_dict["video_width"]
                         video_dict["height"] = video_dict["video_height"]
                         video_dict["crawler_rule"] = json.dumps(self.rule_dict)
-                        video_dict["user_id"] = "-1"
+                        video_dict["user_id"] = self.our_uid
                         video_dict["publish_time"] = video_dict["publish_time_str"]
                         d_obj = self.find_video_url(video_id)
                         video_dict["video_url"] = d_obj["url"]