【问题标题】:http.client.RemoteDisconnected: Remote end closed connection without response SELENIUM/PYTHONhttp.client.RemoteDisconnected:远程结束关闭连接,没有响应 SELENIUM/PYTHON
【发布时间】: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


【解决方案1】:

这可能不是您造成的问题,而是您尝试访问的网站造成的问题。 正如您在上面的堆栈跟踪中显示的那样,您收到的错误是Connection abortedRemote Disconnected 错误,这意味着连接中断或什至没有创建。 当连接的一侧意外关闭套接字时,通常会发生中止/拒绝异常。 除了验证它是否不是您的互联网连接之外,您实际上无能为力,这会导致该问题。 这不是 python 或 selenium 错误。

【讨论】:

    猜你喜欢
    • 2020-12-30
    • 2017-03-12
    • 1970-01-01
    • 2018-06-14
    • 2021-08-20
    • 1970-01-01
    • 2023-01-15
    • 2021-04-09
    • 1970-01-01
    相关资源
    最近更新 更多