Explorar el Código

update 西瓜,快手定时启动改为crontab

lierqiang hace 2 años
padre
commit
573db662cf
Se han modificado 2 ficheros con 20 adiciones y 24 borrados
  1. 12 14
      kuaishou/kuaishou_main/run_kuaishou_follow.py
  2. 8 10
      xigua/xigua_main/run_xigua_follow.py

+ 12 - 14
kuaishou/kuaishou_main/run_kuaishou_follow.py

@@ -13,20 +13,18 @@ from kuaishou.kuaishou_follow.kuaishou_follow import Follow
 
 
 def main(log_type, crawler, strategy, oss_endpoint, env, machine):
-    while True:
-        try:
-            Common.logger(log_type, crawler).info('开始抓取 快手 定向榜\n')
-            Follow.get_follow_videos(log_type=log_type,
-                                     crawler=crawler,
-                                     strategy=strategy,
-                                     oss_endpoint=oss_endpoint,
-                                     env=env,
-                                     machine=machine)
-            Common.del_logs(log_type, crawler)
-            Common.logger(log_type, crawler).info('抓取完一轮\n')
-            break
-        except Exception as e:
-            Common.logger(log_type, crawler).info(f"快手定向榜异常,触发报警:{e}\n")
+    try:
+        Common.logger(log_type, crawler).info('开始抓取 快手 定向榜\n')
+        Follow.get_follow_videos(log_type=log_type,
+                                 crawler=crawler,
+                                 strategy=strategy,
+                                 oss_endpoint=oss_endpoint,
+                                 env=env,
+                                 machine=machine)
+        Common.del_logs(log_type, crawler)
+        Common.logger(log_type, crawler).info('抓取完一轮\n')
+    except Exception as e:
+        Common.logger(log_type, crawler).info(f"快手定向榜异常,触发报警:{e}\n")
             # Feishu.bot(log_type, crawler, f"快手定向榜异常,触发报警:{e}")
 
 

+ 8 - 10
xigua/xigua_main/run_xigua_follow.py

@@ -13,16 +13,14 @@ from common.feishu import Feishu
 
 
 def main(log_type, crawler, strategy, oss_endpoint, env, machine):
-    while True:
-        try:
-            Common.logger(log_type, crawler).info('开始抓取 西瓜视频 定向榜\n')
-            Follow.get_follow_videos(log_type, crawler, strategy, oss_endpoint, env, machine)
-            Common.del_logs(log_type, crawler)
-            Common.logger(log_type, crawler).info('抓取完一轮,休眠 1 分钟\n')
-            time.sleep(60)
-        except Exception as e:
-            Common.logger(log_type, crawler).info(f"西瓜视频异常,触发报警:{e}\n")
-            Feishu.bot(log_type, crawler, f"{e}")
+    try:
+        Common.logger(log_type, crawler).info('开始抓取 西瓜视频 定向榜\n')
+        Follow.get_follow_videos(log_type, crawler, strategy, oss_endpoint, env, machine)
+        Common.del_logs(log_type, crawler)
+        Common.logger(log_type, crawler).info('抓取完一轮,休眠 1 分钟\n')
+    except Exception as e:
+        Common.logger(log_type, crawler).info(f"西瓜视频异常,触发报警:{e}\n")
+        Feishu.bot(log_type, crawler, f"{e}")
 
 
 if __name__ == "__main__":