![](/img/trans.png)
[英]Python Webscraping Error ('Connection aborted.', OSError(“(10060, 'WSAETIMEDOUT')”))
[英]Python-requests [('Connection aborted.', TimeoutError(10060) ]
我正在使用带有requests 2.23.0库的Python 3.7并尝试抓取网站,但收到以下错误消息:
('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
我使用了代理但没有运气,我也尝试指定timeout ,仍然面临同样的问题。
当我通过浏览器访问该网站时,该网站运行良好
我在其他一些网站上使用了相同的代码,效果很好。
任何形式的帮助都非常感谢。
-我能够捕捉到异常,但我想避免它并实际访问该网站
这是代码(就像尝试访问网站一样简单):
from requests import get
try:
agent = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'}
url = "the url I'm trying to access"
html = get(url, headers = agent)
except (Exception) as error :
print ("Error", error)
这可能与网站的安全性有关吗? 我想找到一种解决方法
由于声誉低下,我无法发表评论,所以作为答案发布,我想你会在下面的链接中找到你的答案:
我使用带有用户代理选项的 selenium 并且能够访问该网站
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36' options.add_argument('user-agent={0}'.format(user_agent))
非常感谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.