Browse Source

update 祝福圈子、xiaoniangaoplus

piaoquan 1 year ago
parent
commit
e69b67ee3a

+ 4 - 4
main/process_offline.sh

@@ -74,7 +74,7 @@ else
 fi
 
 # 小年糕-rule
-if [[ "$time" > "21:00:00"  &&  "$time" < "21:59:59" || "$time" > "12:00:00"  &&  "$time" < "12:29:59" ]];then
+if [[ "$time" > "21:00:00"  &&  "$time" < "21:59:59" ]];then
   echo "$(date "+%Y-%m-%d %H:%M:%S") 开始启动 小年糕-rule 爬虫脚本任务" >> ${log_path}
 #  ps aux | grep run_htzf | grep -v grep | awk '{print $2}' | xargs kill -9
 #  ps aux | grep run_ganggangdouchuan | grep -v grep | awk '{print $2}' | xargs kill -9
@@ -97,7 +97,7 @@ fi
 
 
 # 小年糕+
-if [[ "$time" > "10:00:00"  &&  "$time" < "11:59:59" || "$time" > "19:00:00"  &&  "$time" < "20:59:59" ]];then
+if [[ "$time" > "07:00:00"  &&  "$time" < "08:59:59" || "$time" > "19:00:00"  &&  "$time" < "20:59:59" || "$time" > "13:00:00"  &&  "$time" < "14:59:59" || "$time" > "17:00:00"  &&  "$time" < "17:59:59" ]];then
   echo "$(date "+%Y-%m-%d %H:%M:%S") 开始启动 小年糕+ 爬虫脚本任务" >> ${log_path}
 #  ps aux | grep run_htzf | grep -v grep | awk '{print $2}' | xargs kill -9
 #  ps aux | grep run_ganggangdouchuan | grep -v grep | awk '{print $2}' | xargs kill -9
@@ -120,7 +120,7 @@ fi
 
 
 # 祝福圈子
-if [[ "$time" > "07:00:00"  &&  "$time" < "08:59:59" || "$time" > "13:00:00"  &&  "$time" < "13:59:59" ]];then
+if [[ "$time" > "10:00:00"  &&  "$time" < "11:59:59" || "$time" > "15:00:00"  &&  "$time" < "15:59:59" ]];then
   echo "$(date "+%Y-%m-%d %H:%M:%S") 开始启动 祝福圈子 爬虫脚本任务" >> ${log_path}
 #  ps aux | grep run_htzf | grep -v grep | awk '{print $2}' | xargs kill -9
 #  ps aux | grep run_ganggangdouchuan | grep -v grep | awk '{print $2}' | xargs kill -9
@@ -146,7 +146,7 @@ fi
 
 
 
-if [[ "$time" > "14:00:00"  &&  "$time" < "14:00:59" || "$time" > "22:00:00"  &&  "$time" < "22:00:59" ]];then
+if [[ "$time" > "13:00:00"  &&  "$time" < "13:59:59" || "$time" > "16:00:00"  &&  "$time" < "18:59:59" || "$time" > "22:00:00"  &&  "$time" < "23:59:59" ]];then
   echo "$(date "+%Y-%m-%d %H:%M:%S") 爬虫脚本任务结束" >> ${log_path}
 #  ps aux | grep run_htzf | grep -v grep | awk '{print $2}' | xargs kill -9
 #  ps aux | grep run_ganggangdouchuan | grep -v grep | awk '{print $2}' | xargs kill -9

+ 12 - 10
xiaoniangaoplus/xiaoniangaoplus/xiaoniangao_plus_scheduling2.py

@@ -3,6 +3,7 @@
 # @Time: 2023/9/27
 import json
 import os
+import random
 import sys
 import time
 import uuid
@@ -39,7 +40,7 @@ class XiaoNianGaoPlusRecommend:
 
     def __init__(self, log_type, crawler, env, rule_dict, our_uid):
         self.mq = None
-        self.platform = "小年糕+"
+        self.platform = "xiaoniangaoplus"
         self.download_cnt = 0
         self.element_list = []
         self.count = 0
@@ -55,7 +56,7 @@ class XiaoNianGaoPlusRecommend:
             chromedriverExecutable = "/Users/piaoquan/Downloads/chromedriver"
 
         Common.logger(self.log_type, self.crawler).info("启动微信")
-        Common.logging(self.log_type, self.crawler, self.env, '启动微信')
+        # Common.logging(self.log_type, self.crawler, self.env, '启动微信')
         # 微信的配置文件
         caps = {
             "platformName": "Android",
@@ -96,7 +97,7 @@ class XiaoNianGaoPlusRecommend:
             try:
                 if self.driver.find_elements(By.ID, "com.tencent.mm:id/f2s"):
                     Common.logger(self.log_type, self.crawler).info("微信启动成功")
-                    Common.logging(self.log_type, self.crawler, self.env, '微信启动成功')
+                    # Common.logging(self.log_type, self.crawler, self.env, '微信启动成功')
                     AliyunLogger.logging(
                         code="1000",
                         platform=self.platform,
@@ -107,7 +108,7 @@ class XiaoNianGaoPlusRecommend:
                     break
                 elif self.driver.find_element(By.ID, "com.android.systemui:id/dismiss_view"):
                     Common.logger(self.log_type, self.crawler).info("发现并关闭系统下拉菜单")
-                    Common.logging(self.log_type, self.crawler, self.env, '发现并关闭系统下拉菜单')
+                    # Common.logging(self.log_type, self.crawler, self.env, '发现并关闭系统下拉菜单')
                     AliyunLogger.logging(
                         code="1000",
                         platform=self.platform,
@@ -172,7 +173,7 @@ class XiaoNianGaoPlusRecommend:
             try:
                 self.driver.find_element(By.XPATH, xpath)
                 Common.logger(self.log_type, self.crawler).info("切换到WebView成功\n")
-                Common.logging(self.log_type, self.crawler, self.env, '切换到WebView成功\n')
+                # Common.logging(self.log_type, self.crawler, self.env, '切换到WebView成功\n')
                 AliyunLogger.logging(
                     code="1000",
                     platform=self.platform,
@@ -311,7 +312,7 @@ class XiaoNianGaoPlusRecommend:
             if video_title_element is None:
                 return
             Common.logger(self.log_type, self.crawler).info("点击标题,进入视频详情页")
-            Common.logging(self.log_type, self.crawler, self.env, "点击标题,进入视频详情页")
+            # Common.logging(self.log_type, self.crawler, self.env, "点击标题,进入视频详情页")
             AliyunLogger.logging(
                 code="1000",
                 platform=self.platform,
@@ -330,12 +331,13 @@ class XiaoNianGaoPlusRecommend:
             video_dict["strategy"] = self.log_type
             video_dict["out_video_id"] = video_dict["video_id"]
             video_dict["crawler_rule"] = json.dumps(self.rule_dict)
-            video_dict["user_id"] = self.our_uid
+            video_dict["user_id"] = random.choice(self.our_uid)
             video_dict["publish_time"] = video_dict["publish_time_str"]
             self.mq.send_msg(video_dict)
             # print(video_dict)
             self.download_cnt += 1
             self.driver.press_keycode(AndroidKey.BACK)
+            # self.driver.back()
             time.sleep(5)
 
     def get_video_info(self, video_element):
@@ -361,7 +363,7 @@ class XiaoNianGaoPlusRecommend:
         page = 0
         if self.search_elements('//*[@class="list-list--list"]') is None:
             Common.logger(self.log_type, self.crawler).info("窗口已销毁\n")
-            Common.logging(self.log_type, self.crawler, self.env, '窗口已销毁\n')
+            # Common.logging(self.log_type, self.crawler, self.env, '窗口已销毁\n')
             AliyunLogger.logging(
                 code="3000",
                 platform=self.platform,
@@ -387,7 +389,7 @@ class XiaoNianGaoPlusRecommend:
         print("下滑完成")
         # time.sleep(100)
         Common.logger(self.log_type, self.crawler).info("已抓取完一组,休眠 5 秒\n")
-        Common.logging(self.log_type, self.crawler, self.env, "已抓取完一组,休眠 5 秒\n")
+        # Common.logging(self.log_type, self.crawler, self.env, "已抓取完一组,休眠 5 秒\n")
         AliyunLogger.logging(
             code="1000",
             platform=self.platform,
@@ -404,7 +406,7 @@ def run():
                   "favorite_cnt": {"min": 0, "max": 0},
                   "videos_cnt": {"min": 5000, "max": 0},
                   "share_cnt": {"min": 0, "max": 0}}
-    XiaoNianGaoPlusRecommend("recommend", "xiaoniangao", "dev", rule_dict1, 6267141)
+    XiaoNianGaoPlusRecommend("recommend", "xiaoniangaoplus", "prod", rule_dict1, [64120158, 64120157, 63676778])
 
 
 if __name__ == "__main__":

+ 3 - 3
zhufuquanzi/zhufuquanzi_recommend/zhufuquanzi_recommend_new.py

@@ -36,7 +36,7 @@ class ZFQZRecommend:
             chromedriverExecutable = "/Users/piaoquan/Downloads/chromedriver"
 
         Common.logger(log_type, crawler).info("启动微信")
-        Common.logging(log_type, crawler, env, '启动微信')
+        # Common.logging(log_type, crawler, env, '启动微信')
         caps = {
             "platformName": "Android",
             "devicesName": "Android",
@@ -60,13 +60,13 @@ class ZFQZRecommend:
         }
         try:
             driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
-        except:
+        except Exception as e:
             AliyunLogger.logging(
                 code="3002",
                 platform=ZFQZRecommend.platform,
                 mode=log_type,
                 env=env,
-                message="appium 启动异常"
+                message="appium 启动异常, 报错原因是{}".format(e)
             )
             return
         driver.implicitly_wait(30)