From cf60bcfe4305ce2f362497f2534470d83b461e4f Mon Sep 17 00:00:00 2001 From: Bhaskar B Sarkar <71055334+bhaskar-29@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:38:25 +0530 Subject: [PATCH] Updated Chrome Driver code Updated Chrome Driver code using ChromeDriverManager. In many cases, the path specified is not detected and throws an error on running. Therefore, I would suggest you use this. Hope you like it. --- shutterscrape.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shutterscrape.py b/shutterscrape.py index ef86679..7c71a0e 100644 --- a/shutterscrape.py +++ b/shutterscrape.py @@ -1,4 +1,5 @@ from selenium import webdriver +from webdriver_manager.chrome import ChromeDriverManager #use to initialize driver in a better way without having chromedriver path mentioned. from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec @@ -33,7 +34,7 @@ def inp(text): def videoscrape(): try: - driver = webdriver.Chrome() + driver = webdriver.Chrome(ChromeDriverManager().install()) #This installs or finds the new version of chrome driver if not available and links to path automatically. driver.maximize_window() for i in range(1, searchPage + 1): url = "https://www.shutterstock.com/video/search/" + searchTerm + "?page=" + str(i) @@ -76,7 +77,7 @@ def imagescrape(): try: chrome_options = Options() chrome_options.add_argument("--no-sandbox") - driver = webdriver.Chrome(chrome_options=chrome_options) + driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options) driver.maximize_window() for i in range(1, searchPage + 1): url = "https://www.shutterstock.com/search?searchterm=" + searchTerm + "&sort=popular&image_type=" + image_type + "&search_source=base_landing_page&language=en&page=" + str(i)