问题
I'm in the process of scraping pdfs from a website using selenium and chrome webdriver. I use the following, pulling the site
from a list:
driver.get(site)
source = driver.page_source
...
...
driver.quit()
But I keep getting the following error, about 6,000 observations down my site
list:
Traceback (most recent call last):
File "<stdin>", line 127, in <module>
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 323, in get self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: chrome=63.0.3239.84)
(Driver info: chromedriver=2.33.506092
(733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.10.0-40-generic x86_64)
I've tried refreshing the source page at shorter intervals (every 200 searches, but should I go shorter?).
How do I extend selenium's 120sec timeout limit?
回答1:
This error message...
Traceback (most recent call last):
File "<stdin>", line 127, in <module>
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 323, in get self.execute(Command.GET, {'url': url})
.
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: chrome=63.0.3239.84)
(Driver info: chromedriver=2.33.506092
(733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.10.0-40-generic x86_64)
...implies that the webdriver instance cannot establish a connection with the site url
and timeout occurs.
Your main issue is the version compatibility between the binaries you are using as follows :
- You are using ChromeDriver v2.33
- Release Notes of ChromeDriver v2.33 clearly mentions the following :
Supports Chrome v60-62
- You are using chrome=63.0
- Selenium Version is unknown to us.
So there is a clear mismatch between the ChromeDriver v2.33 and the Chrome Browser v63.0 you are using. Hence ChromeDriver is unable to spawn the new Chrome Browser process.
Solution
- Update ChromeDriver to recent v2.35 level.
- Upgrade Chrome to stable Chrome v64.x levels. (as per ChromeDriver v2.35 release notes)
- Upgrade Selenium to current levels Version 3.9.1.
- Clean and Re-Build your project through your IDE.
- Clear the Browser Cache.
- Run CCleaner tool to wipe off all the OS chores before and after execution of your Test Suite.
- If your Web Browser base version is too old, uninstall the Web Browser through Revo Uninstaller with Moderate Scan and install a recent GA Released version of the Web Browser.
- Execute your Tests.
来源:https://stackoverflow.com/questions/48916783/python-selenium-chromedriver-timeoutexception