Take Screenshot Of Multiple Urls Using Selenium (python)
I am trying to take a screenshot of multiple websites using python selenium library. Here I have an array of website like data = array of website [ 'google.com', 'youtube.com'...
Solution 1:
You should spend some time reading the docs for the different statements that you are using. You are using several incorrectly.
I think this will work. One issue may be that if the page loads long, the browser will not be allowed to navigate to a new page with browser.get()
. You might try sending an ESC key or one of the many other options you can find by googling.
I added the site to the "took too long" message so you would know which ones didn't finish loading in time.
browser = webdriver.Chrome('/Users/wk/Desktop/checkSafeContent/chromedriver')
browser.set_page_load_timeout(30)
browser.maximize_window()
for index, url in enumerate(data):
try:
browser.get('http://' + data[index])
except:
print(data[index] + ' took too long')
else:
# where images saved
browser.save_screenshot('/.../' + str(index) + '.png')
browser.quit()
Post a Comment for "Take Screenshot Of Multiple Urls Using Selenium (python)"