Added xpath method for obtaining image when normal fails
This commit is contained in:
@@ -60,9 +60,10 @@ def find_amazon_link(update: Update, context: CallbackContext) -> None:
|
||||
driver.get(msg)
|
||||
logging.info("Scraping information and closing browser")
|
||||
soup = BeautifulSoup(driver.page_source, "lxml")
|
||||
etree_soup = BeautifulSoup(driver.page_source, "html.parser")
|
||||
|
||||
logging.info("Getting title...")
|
||||
title, price, image = parser.get_title(soup), parser.get_price(soup), parser.get_image(soup)
|
||||
title, price, image = parser.get_title(soup), parser.get_price(soup), parser.get_image(soup, etree_soup)
|
||||
if title == "":
|
||||
logging.info(f"Title not found, not a valid product or captcha")
|
||||
captcha = AmazonCaptcha.fromdriver(driver)
|
||||
@@ -80,8 +81,9 @@ def find_amazon_link(update: Update, context: CallbackContext) -> None:
|
||||
driver.get(msg)
|
||||
logging.info("Scraping information")
|
||||
soup = BeautifulSoup(driver.page_source, "lxml")
|
||||
etree_soup = BeautifulSoup(driver.page_source, "html.parser")
|
||||
logging.info("Getting title...")
|
||||
title, price, image = parser.get_title(soup), parser.get_price(soup), parser.get_image(soup)
|
||||
title, price, image = parser.get_title(soup), parser.get_price(soup), parser.get_image(soup, etree_soup)
|
||||
if title == "":
|
||||
logging.info(f"Title not found, not a valid product or failed captcha")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user