|
|
@@ -207,6 +207,21 @@ class JdCrawlerV2:
|
|
|
return fp.get("estimatedPrice", "") or ""
|
|
|
return ""
|
|
|
|
|
|
+ def get_heshu(self,full_title):
|
|
|
+ last_box = None
|
|
|
+ last_bottle = None
|
|
|
+ for match in re.finditer(r"(\d+)(盒|瓶)", full_title):
|
|
|
+ if match.group(2) == '盒':
|
|
|
+ last_box = match
|
|
|
+ else: # 瓶
|
|
|
+ last_bottle = match
|
|
|
+ if last_box:
|
|
|
+ return int(last_box.group(1))
|
|
|
+ elif last_bottle:
|
|
|
+ return int(last_bottle.group(1))
|
|
|
+ else:
|
|
|
+ return 1
|
|
|
+
|
|
|
def parse(self, ware_list):
|
|
|
|
|
|
for w in ware_list:
|
|
|
@@ -252,11 +267,7 @@ class JdCrawlerV2:
|
|
|
sales = w.get("totalSales", "")
|
|
|
shop_id = w.get("shopId", "")
|
|
|
shop_name = w.get("shopName", "")
|
|
|
- heshu_m = re.search(r"(\d+)(盒|瓶)", full_title)
|
|
|
- if heshu_m:
|
|
|
- heshu_count = int(heshu_m.group(1))
|
|
|
- else:
|
|
|
- heshu_count = 1
|
|
|
+ heshu_count = self.get_heshu(full_title)
|
|
|
final_price = self._estimated_price(w)
|
|
|
jd_price = w.get("jdPrice", "")
|
|
|
low_price = final_price if final_price else jd_price
|
|
|
@@ -548,6 +559,7 @@ class JdCrawlerV2:
|
|
|
self.sleep(3, 5)
|
|
|
|
|
|
kw = quote(str(keyword or ""), safe="")
|
|
|
+ self._start_listen()
|
|
|
self.driver.get(
|
|
|
f"https://search.jd.com/Search?keyword={kw}&enc=utf-8&wq={kw}", timeout=15
|
|
|
)
|
|
|
@@ -635,7 +647,7 @@ class JdCrawlerV2:
|
|
|
logger.info("获取到账号:%s,代理ip:%s", self.account_name, self.ip)
|
|
|
|
|
|
# # # 每次选取账号,立马账号使用时间
|
|
|
- update_sql = f""" UPDATE `retrieve_collect_equipment_account` SET `status`= %s, `update_time`= %s WHERE `name` = %s; """
|
|
|
+ update_sql = f""" UPDATE `retrieve_collect_equipment_account` SET `status`= %s, `update_time`= %s WHERE `username` = %s; """
|
|
|
self.db.execute(update_sql, (0, int(time.time()), self.account_name))
|
|
|
|
|
|
try:
|