From 38fdf3bb50983d8900f8958eb73c7b7091797acb Mon Sep 17 00:00:00 2001 From: Alejandro Perez Lopez Date: Fri, 22 Sep 2023 12:37:05 +0200 Subject: [PATCH] Move logic in case the captcha resolution fails or we can't extract the data after the captcha resolution to avoid errors --- bot/bot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/bot.py b/bot/bot.py index e689ab3..8969562 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -119,13 +119,13 @@ def find_amazon_link(update: Update, context: CallbackContext) -> None: logging.info("Re-loading Amazon webpage") page_html = load_page(url=amazon_url_with_referer, driver=chrome_driver, screenshot_type="_aftercaptcha") product_data = scrape_data(page_html) - - if not product_data: - logging.info("Unable to get the product information") - context.bot.send_message(chat_id=chat_id, text="Unable to get product attributes from the provided url", reply_to_message_id=message_id) - return else: logging.info("Couldn't solve the captcha, if there was any") + + if not product_data: #if after applying the captcha we don't have any data yet, stop the execution and reply to the user + logging.info("Unable to get the product information") + context.bot.send_message(chat_id=chat_id, text="Unable to get product attributes from the provided url", reply_to_message_id=message_id) + return logging.info(f"Product information found: {product_data}")