Fixed data lose after captcha. Maybe...
This commit is contained in:
parent
19821b22d6
commit
71825351c8
|
@ -70,8 +70,11 @@ class StolichkiDriver(uc.Chrome):
|
||||||
resp_url = message["params"]["response"]["url"]
|
resp_url = message["params"]["response"]["url"]
|
||||||
|
|
||||||
if re.fullmatch(url_re, resp_url):
|
if re.fullmatch(url_re, resp_url):
|
||||||
body_ = self.execute_cdp_cmd("Network.getResponseBody", {"requestId": request_id})
|
try:
|
||||||
body = json.loads(body_['body'])
|
body_ = self.execute_cdp_cmd("Network.getResponseBody", {"requestId": request_id})
|
||||||
|
body = json.loads(body_['body'])
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
@ -110,7 +113,7 @@ class StolichkiDriver(uc.Chrome):
|
||||||
if self.wait_for_presence():
|
if self.wait_for_presence():
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
continue
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import re
|
import re
|
||||||
import time
|
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
|
@ -109,8 +108,6 @@ class ByfarmCategoryParser(BaseCategoryParser):
|
||||||
|
|
||||||
if (product_info and product_farms) and (product_farms.get("status") == product_info.get("status")):
|
if (product_info and product_farms) and (product_farms.get("status") == product_info.get("status")):
|
||||||
return Product(product_info["drug"], product_farms["stores"])
|
return Product(product_info["drug"], product_farms["stores"])
|
||||||
|
|
||||||
self.driver.refresh()
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -118,7 +115,7 @@ class ByfarmCategoryParser(BaseCategoryParser):
|
||||||
try:
|
try:
|
||||||
ActionChains(self.driver).scroll_by_amount(0, 1300).scroll_by_amount(0, -100).perform()
|
ActionChains(self.driver).scroll_by_amount(0, 1300).scroll_by_amount(0, -100).perform()
|
||||||
|
|
||||||
return self.driver.wait_for_presence(by=By.CLASS_NAME, value="tr-start-store", delay=60)
|
return self.driver.wait_for_presence(by=By.CLASS_NAME, value="tr-start-store")
|
||||||
|
|
||||||
except:
|
except:
|
||||||
if not self.driver.handle_captcha():
|
if not self.driver.handle_captcha():
|
||||||
|
|
Loading…
Reference in New Issue