Fixed data lose after captcha. Maybe...

This commit is contained in:
Анатолий Богомолов 2023-12-31 17:16:44 +10:00
parent 19821b22d6
commit 71825351c8
2 changed files with 7 additions and 7 deletions

View File

@ -70,8 +70,11 @@ class StolichkiDriver(uc.Chrome):
resp_url = message["params"]["response"]["url"]
if re.fullmatch(url_re, resp_url):
body_ = self.execute_cdp_cmd("Network.getResponseBody", {"requestId": request_id})
body = json.loads(body_['body'])
try:
body_ = self.execute_cdp_cmd("Network.getResponseBody", {"requestId": request_id})
body = json.loads(body_['body'])
except:
continue
return body
@ -110,7 +113,7 @@ class StolichkiDriver(uc.Chrome):
if self.wait_for_presence():
return True
except:
return False
continue
continue

View File

@ -1,5 +1,4 @@
import re
import time
from loguru import logger
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")):
return Product(product_info["drug"], product_farms["stores"])
self.driver.refresh()
return None
@ -118,7 +115,7 @@ class ByfarmCategoryParser(BaseCategoryParser):
try:
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:
if not self.driver.handle_captcha():