Browse Source

update 西瓜启动脚本添加

lierqiang 2 years ago
parent
commit
1967db64cb
2 changed files with 45 additions and 3 deletions
  1. 42 0
      xigua/xigua_main/run_xigua_search.py
  2. 3 3
      xigua/xigua_search/xugua_search.py

+ 42 - 0
xigua/xigua_main/run_xigua_search.py

@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+# @Author: lierqiang
+# @Time: 2023/3/13
+import argparse
+import os
+import sys
+import time
+
+sys.path.append(os.getcwd())
+from common.common import Common
+from xigua.xigua_search.xugua_search import Search
+from common.feishu import Feishu
+
+
+def main(log_type, crawler, strategy, oss_endpoint, env, machine):
+    try:
+        Common.logger(log_type, crawler).info('开始抓取 西瓜视频 搜索\n')
+        Search.get_search_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__":
+    parser = argparse.ArgumentParser()  ## 新建参数解释器对象
+    parser.add_argument('--log_type', type=str)  ## 添加参数,注明参数类型
+    parser.add_argument('--crawler')  ## 添加参数
+    parser.add_argument('--strategy')  ## 添加参数
+    parser.add_argument('--our_uid')  ## 添加参数
+    parser.add_argument('--oss_endpoint')  ## 添加参数
+    parser.add_argument('--env')  ## 添加参数
+    parser.add_argument('--machine')  ## 添加参数
+    args = parser.parse_args()  ### 参数赋值,也可以通过终端赋值
+    # print(args)
+    main(log_type=args.log_type,
+         crawler=args.crawler,
+         strategy=args.strategy,
+         oss_endpoint=args.oss_endpoint,
+         env=args.env,
+         machine=args.machine)

+ 3 - 3
xigua/xigua_search/xugua_search.py

@@ -23,7 +23,7 @@ from common.feishu import Feishu
 from common.publish import Publish
 
 
-class Follow:
+class Search:
     platform = "西瓜视频"
     tag = "西瓜视频爬虫,搜索爬虫策略"
 
@@ -851,12 +851,12 @@ class Follow:
                                   env=env,
                                   machine=machine)
         except Exception as e:
-            Common.logger(log_type, crawler).error(f"get_follow_videos:{e}\n")
+            Common.logger(log_type, crawler).error(f"get_search_videos:{e}\n")
 
 
 if __name__ == '__main__':
     # print(Follow.get_signature("follow", "xigua", "95420624045", "local"))
-    Follow.get_search_videos('search', 'xigua', 'xigua_search', 'out', 'dev', 'local')
+    Search.get_search_videos('search', 'xigua', 'xigua_search', 'out', 'dev', 'local')
 
     # Follow.get_videolist(log_type="follow",
     #                      crawler="xigua",