![](/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.