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()