Browse Source

添加es访问查询异常时捕获

dzr 1 month ago
parent
commit
e3c1a3b88f
1 changed files with 8 additions and 1 deletions
  1. 8 1
      zbytb/crawler/spiders/ListPageSpider.py

+ 8 - 1
zbytb/crawler/spiders/ListPageSpider.py

@@ -122,7 +122,14 @@ class CrawlListPageSpider:
                 **label_item,
             }
             if not self.dedup.get(competehref):
-                info["count"] = es_query(info["title"], info["l_np_publishtime"])
+                try:
+                    count = es_query(info["title"], info["l_np_publishtime"])
+                except Exception as e:
+                    logger.error(f"es 调用失败, 原因:{type(e).__name__}")
+                    logger.exception(e)
+                    count = 0
+
+                info["count"] = count
                 results.append(info)
                 self.dedup.add(competehref)