diff --git a/stolichki/driver.py b/stolichki/driver.py index 56cbae4..1f1b423 100644 --- a/stolichki/driver.py +++ b/stolichki/driver.py @@ -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 diff --git a/stolichki/parsers/category.py b/stolichki/parsers/category.py index 98d31a7..fa13e3b 100644 --- a/stolichki/parsers/category.py +++ b/stolichki/parsers/category.py @@ -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():