From e9ac547c8b80b95ae2f9a16cda333e5ac3b71356 Mon Sep 17 00:00:00 2001 From: saif Date: Wed, 13 Aug 2025 13:07:36 +0500 Subject: [PATCH] clear resources --- scrapper.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/scrapper.py b/scrapper.py index cfcf64f..8264767 100644 --- a/scrapper.py +++ b/scrapper.py @@ -156,17 +156,19 @@ def get_amazon_ranks(url, marketplace, ratingPrefix, keyword, page, count): return count -driver = get_driver() - -for keyword in keywords: - for marketplace, details in marketplaces.items(): - if marketplace == 'AMAZON_USA': - url = details['url'] - ratingPrefix = details['ratingPrefix'] - count =1 - for i in range(1, MAX_PAGE): - count = get_amazon_ranks(url, marketplace, ratingPrefix, keyword, i, count) - if count == -1: - break - sleep(3) -driver.quit() +try : + driver = get_driver() + for keyword in keywords: + for marketplace, details in marketplaces.items(): + if marketplace == 'AMAZON_USA': + url = details['url'] + ratingPrefix = details['ratingPrefix'] + count =1 + for i in range(1, MAX_PAGE): + count = get_amazon_ranks(url, marketplace, ratingPrefix, keyword, i, count) + if count == -1: + break + sleep(3) +finally: + print("[INFO] Closing WebDriver...") + driver.quit()