問題描述
我正在使用 selenium 和 chrome webdriver 從網站上抓取 pdf.我使用以下內容,從列表中拉出 site
:
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()
但我不斷收到以下錯誤,我的 site
列表中有大約 6,000 次觀察:
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)
我嘗試過以更短的時間間隔刷新源頁面(每 200 次搜索,但我應該縮短嗎?).
I've tried refreshing the source page at shorter intervals (every 200 searches, but should I go shorter?).
如何延長 selenium 的 120 秒超時限制?
How do I extend selenium's 120sec timeout limit?
推薦答案
這個錯誤信息...
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)
...表示 webdriver 實例無法與 site url
建立連接并發生 timeout.
...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 :
- 您正在使用 ChromeDriver v2.33
- ChromeDriver v2.33 明確提及以下內容:
支持 Chrome v60-62
- 您正在使用 chrome=63.0
- Selenium 版本我們不知道.
- You are using chrome=63.0
- Selenium Version is unknown to us.
- 將 ChromeDriver 更新到最近的 v2.35 級別.
- 將 Chrome 升級到穩定的 Chrome v64.x 級別.(根據 ChromeDriver v2.35 發行說明)
- 將 Selenium 升級到當前級別 3.9.1 版.
- 清理并通過您的IDE重新構建您的項目.
- 清除瀏覽器緩存.
- 運行 CCleaner 工具,在執行 之前和之后清除所有操作系統雜務測試套件.
- 如果您的 Web 瀏覽器 基礎版本太舊,請通過 Web 瀏覽器" rel="nofollow noreferrer">Revo Uninstaller 使用 Moderate Scan 并安裝 Web 瀏覽器 的最新 GA 發布 版本.
- 執行您的測試.
- 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.
因此,您使用的 ChromeDriver v2.33 和 Chrome 瀏覽器 v63.0 之間存在明顯的不匹配.因此 ChromeDriver 無法生成新的 Chrome 瀏覽器 進程.
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.
這篇關于python/selenium/chromedriver TimeoutException的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!