Skip to content

Commit

Permalink
Updated Chrome Driver code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bhaskar-29 authored Oct 1, 2020
1 parent 6ef24c0 commit cf60bcf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shutterscrape.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cf60bcf

Please sign in to comment.