Browse Source

抖音优化

zhangyong 1 year ago
parent
commit
faf15b94c5
1 changed files with 18 additions and 16 deletions
  1. 18 16
      douyin/douyin_author/douyin_author_scheduling_new.py

+ 18 - 16
douyin/douyin_author/douyin_author_scheduling_new.py

@@ -56,25 +56,26 @@ class DouyinauthorScheduling:
     def get_videoList(cls, log_type, crawler, user_dict, rule_dict, env):
         mq = MQ(topic_name="topic_crawler_etl_" + env)
         next_cursor = 0
+        special = 0
         while True:
             flag = user_dict["link"].split("_")[0]
             if flag == "V1":
+                special = 0.01
                 rule_dict = {
                     "like_cnt": {"min": 10000, "max": 0},
                     'period': {"min": 90, "max": 90},
-                    'special': 0.01
                 }
             elif flag == "V2":
+                special = 0.01
                 rule_dict = {
                     "like_cnt": {"min": 2000, "max": 0},
                     'period': {"min": 90, "max": 90},
-                    'special': 0.01
                 }
             elif flag == "V3":
+                special = 0.01
                 rule_dict = {
                     "like_cnt": {"min": 100, "max": 0},
                     'period': {"min": 90, "max": 90},
-                    'special': 0.01
                 }
             cookie = cls.get_cookie(log_type, crawler, env)["cookie"]
             if user_dict['link'][0] == "V":
@@ -169,19 +170,20 @@ class DouyinauthorScheduling:
                         comment_count = int(data[i].get('statistics').get('comment_count'))  # 评论
                         # collect_count = data[i].get('statistics').get('collect_count')  # 收藏
                         share_count = int(data[i].get('statistics').get('share_count'))  # 转发
-                        if share_count != 0:
-                            video_percent = '%.2f' % (share_count / digg_count)
-                            special = float(rule_dict.get("special", 0.0))
-                            if float(video_percent) < special:
-                                Common.logger(log_type, crawler).info(f"不符合条件:分享/点赞-{video_percent}\n")
-                                AliyunLogger.logging(
-                                    code="2004",
-                                    platform=crawler,
-                                    mode=log_type,
-                                    env=env,
-                                    message=f"不符合条件:分享/点赞-{video_percent},点赞量-{digg_count}\n"
-                                )
-                                continue
+                        if special != 0:
+                            if share_count != 0:
+                                video_percent = '%.2f' % (share_count / digg_count)
+                                special = float(special)
+                                if float(video_percent) < special:
+                                    Common.logger(log_type, crawler).info(f"不符合条件:分享/点赞-{video_percent}\n")
+                                    AliyunLogger.logging(
+                                        code="2004",
+                                        platform=crawler,
+                                        mode=log_type,
+                                        env=env,
+                                        message=f"不符合条件:分享/点赞-{video_percent},点赞量-{digg_count}\n"
+                                    )
+                                    continue
                         video_dict = {'video_title': video_title,
                                       'video_id': video_id,
                                       'play_cnt': 0,