我使用BeautifulSoup和Selenium使用Python已有一段时间,这是我第一次无法从以下站点检索信息:“ https://www.nbe.gov.et/financial/banks.html”,我可以通过常规浏览来访问它,但是将Selenium与chromedriver一起使用时,该页面将不会加载。使用请求时出现以下错误:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ET-NBE.py", line 32, in <module>
res=requests.get(regdict[reg], headers=headers)
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-pack
ages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-pack
ages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-pack
ages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-pack
ages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-pack
ages\requests\adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.nbe.gov.et',
port=443): Max retries exceeded with url: /financial/banks.html (Caused by NewCo
nnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0481A550>
: Failed to establish a new connection: [Errno 11004] getaddrinfo failed'))
我尝试添加用户代理,使用Selenium禁用cookie和隐身模式,该页面永远不会加载,但是当我使用Chrome(不使用Selenium / chromedriver)访问它时,该页面可以正常工作。