【发布时间】:2020-11-04 06:08:05
【问题描述】:
我是网络爬虫的新手,试图访问一个网站但出现太多错误并被告知 (Connection aborted.', OSError("(60, 'ETIMEDOUT').
from bs4 import BeautifulSoup
import requests
urla="https://www.loopnet.com/search/office-space/san-diego-ca/for-lease/?sk=02fa1ad85634ef43bfd21f24bbe3a14a"
source = requests.get(urla).text
print(source)
OSError Traceback(最近一次调用最后一次) ~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 671 标头=标头, --> 672 分块=分块, 1343 尝试: -> 1344 响应。开始() 1345 连接错误除外:
~/opt/anaconda3/lib/python3.7/http/client.py in begin(self) 305 时为真: --> 306 版本、状态、原因 = self._read_status() 307 如果状态!= 继续:
~/opt/anaconda3/lib/python3.7/http/client.py 在 _read_status(self) 第266章 --> 267 行 = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") 268 如果 len(line) > _MAXLINE:
~/opt/anaconda3/lib/python3.7/socket.py in readinto(self, b) 588尝试: --> 589 返回 self._sock.recv_into(b) 590 除了超时:
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py 在 recv_into(self, *args, **kwargs) 317 其他: --> 318 引发 SocketError(str(e)) 319 除了 OpenSSL.SSL.ZeroReturnError:
OSError: (60, 'ETIMEDOUT')
在处理上述异常的过程中,又发生了一个异常:
ProtocolError Traceback(最近一次调用最后一次) ~/opt/anaconda3/lib/python3.7/site-packages/requests/adapters.py 在发送(自我,请求,流,超时,验证,证书,代理) 448 次重试=self.max_retries, --> 449 超时=超时 450)
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked , body_pos, **response_kw) 719次重试=重试.增量( --> 720 方法、url、error=e、_pool=self、_stacktrace=sys.exc_info()[2] 第721章
ConnectionError: ('Connection aborted.', OSError("(60, 'ETIMEDOUT')")) (类似这样)
【问题讨论】:
标签: python