|
@@ -293,7 +293,7 @@ class YaoexCrawler:
|
|
|
return price
|
|
return price
|
|
|
|
|
|
|
|
def search_data(self):
|
|
def search_data(self):
|
|
|
- keyword = ""
|
|
|
|
|
|
|
+ keyword = self.product
|
|
|
if self.brand:
|
|
if self.brand:
|
|
|
keyword = self.brand + " " + self.product
|
|
keyword = self.brand + " " + self.product
|
|
|
if self.product_desc:
|
|
if self.product_desc:
|
|
@@ -323,6 +323,7 @@ class YaoexCrawler:
|
|
|
|
|
|
|
|
if not product.get("item_id"):
|
|
if not product.get("item_id"):
|
|
|
continue
|
|
continue
|
|
|
|
|
+ logger.info(f"爬取到数据{json.dumps(product,ensure_ascii=False)}")
|
|
|
try:
|
|
try:
|
|
|
self.pipeline.storge_data(product)
|
|
self.pipeline.storge_data(product)
|
|
|
logger.info("%s", json.dumps(product, ensure_ascii=False))
|
|
logger.info("%s", json.dumps(product, ensure_ascii=False))
|
|
@@ -334,12 +335,11 @@ class YaoexCrawler:
|
|
|
time.sleep(random.randint(2, 5))
|
|
time.sleep(random.randint(2, 5))
|
|
|
|
|
|
|
|
def run(self):
|
|
def run(self):
|
|
|
- self.search_data()
|
|
|
|
|
- # try:
|
|
|
|
|
- # self.search_data()
|
|
|
|
|
- # except Exception as e:
|
|
|
|
|
- # logger.error(e)
|
|
|
|
|
- # self.is_success = False
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ self.search_data()
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ logger.error(e)
|
|
|
|
|
+ self.is_success = False
|
|
|
logger.info(f"爬取总数{self.pipeline.crawl_count}")
|
|
logger.info(f"爬取总数{self.pipeline.crawl_count}")
|
|
|
return self.pipeline.crawl_count, self.is_success
|
|
return self.pipeline.crawl_count, self.is_success
|
|
|
|
|
|