luojunhui hai 4 meses
pai
achega
fd674bb299
Modificáronse 1 ficheiros con 15 adicións e 3 borrados
  1. 15 3
      coldStartTasks/crawler/weixin_account_crawler.py

+ 15 - 3
coldStartTasks/crawler/weixin_account_crawler.py

@@ -172,9 +172,21 @@ class WeixinAccountCrawler(object):
         :return:
         """
         for page_index in tqdm(range(1, const.MAX_SEARCH_PAGE_NUM + 1), desc='searching: {}'.format(title)):
-            response = self.spider.search_articles(title, page=str(page_index))
-            self.process_search_result(response, inner_account_set)
-            time.sleep(const.SLEEP_SECONDS)
+            try:
+                response = self.spider.search_articles(title, page=str(page_index))
+                self.process_search_result(response, inner_account_set)
+                time.sleep(const.SLEEP_SECONDS)
+            except Exception as e:
+                log(
+                    task="account_crawler_v1",
+                    function="search_title_in_weixin",
+                    message="search title error",
+                    data={
+                        "error": str(e),
+                        "traceback": traceback.format_exc(),
+                        "title": title
+                    }
+                )
 
     def run(self, run_date=None) -> None:
         """