Explorar o código

药师帮增加品牌

zhuoyuncheng hai 1 semana
pai
achega
d0ab6c417f

+ 3 - 2
spiders/yaoshibang/ysb_snapshot_list_crawl.py

@@ -645,8 +645,7 @@ class YaoShiBangSnapshot:
 
                 if self.product in title and self.brand in title:
                     self.is_product_count = 0
-                if self.is_product_count >= 20:
-                    return
+
 
                 dom_idx = list_idx - 1
                 image_ele = goods_wrappers[dom_idx]
@@ -659,6 +658,8 @@ class YaoShiBangSnapshot:
                 except Exception as e:
                     logger.exception("写入数据库失败: %s", e)
 
+            if self.is_product_count >= 20:
+                break
             # 检测下一页
             self.clear_listen_buffer()
             next_button = self.driver.ele("xpath=//div[@class='condition']//div[@class='btn next']")

+ 2 - 2
spiders/yaoshibang/ysbang_crawl.py

@@ -410,13 +410,13 @@ class YsbSpider:
                 if self.product in title and self.brand in title:
                     self.is_product_count = 0
 
-                if self.is_product_count >=20:
-                    return
                 try:
                     self.pipeline.storge_data(product)
                     logger.info("%s", json.dumps(product, ensure_ascii=False))
                 except Exception as e:
                     logger.exception("写入数据库失败: %s", e)
+            if self.is_product_count >= 20:
+                return
 
             page += 1