【发布时间】:2021-10-21 02:47:09
【问题描述】:
我正在使用来自this anwser 的以下代码。
import urllib.request
url = 'https://example.com'
proxy_support = urllib.request.ProxyHandler({'http' : '37.26.86.206',
'https': '37.26.86.206'})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
with urllib.request.urlopen(url) as response:
print(response)
但是,我收到此错误:urllib.error.URLError: <urlopen error Remote end closed connection without response>
我不知道为什么会这样,因为其他人没有这个问题(我可以找到)。这是我的proxy 的问题,还是代码的问题?
注意:所有回溯都是通过 urllib,而不是我的程序
【问题讨论】:
-
免费代理通常已经过时并且无法正常工作。一些门户网站已经知道免费代理,他们可能会阻止它们。最好找一些付费代理或者使用tor 作为代理。或者使用像 scrapestack.com 这样的服务,每个月提供很少的免费请求(即 250)
标签: python proxy urllib urlopen