【发布时间】:2021-10-17 11:31:40
【问题描述】:
我正在使用 selenium - chrome 来抓取页面,有时我在获取网站时会遇到这样的错误:
http.client.RemoteDisconnected: Remote end closed connection without response
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=40097): Max retries exceeded with url: /session/503e38e9827bff7335d467e8ba31cb5c/screenshot (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused'))
我尝试了页面策略和不同的 chrome 选项,例如:
options.page_load_strategy = 'eager'
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument('--enable-features=NetworkServiceInProcess')
options.add_argument('--disable-features=NetworkService')
没有什么能消除我的错误。
我正在容器中使用这样的 chrome 和 chrome 驱动程序版本:
- browserVersion - '92.0.4515.131'
- chromedriverVersion - '92.0.4515.107'
你能帮我解决这个问题吗?
【问题讨论】:
-
您想访问哪个网站?你能ping通那个地址吗?可以在 Chrome 中查看吗?你是企业防火墙吗?
-
我正在尝试访问许多网站,对它们进行 ping 操作并在 Chrome 中查看。问题在到达子页面期间随机发生(有时甚至在达到数百页之后),但如果我重新运行代码,发生错误的页面正常工作。不,我不是公司防火墙。
标签: python selenium google-chrome web-scraping urllib3