更新时间:2022-06-20 18:35:32
我相信你可以这样做:
import urllib2
proxy = urllib2.ProxyHandler({'http': '123.96.220.2:81'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
with open('filename','wb') as f:
f.write(urllib2.urlopen(URL).read())
f.close()
因为 urllib2
没有 urlretrieve
你可以使用 urlopen
来获得同样的效果
since urllib2
doesnt have urlretrieve
you can just use urlopen
to get the same effect
你一定把文档搞糊涂了,因为 urllib2
也没有 FancyURLopener
这就是你收到错误的原因
you must have got the docs confused becuase urllib2
also doesnt have FancyURLopener
thats why youre getting the error
urllib2
在处理代理等时要好得多
urllib2
is much better when handling proxies and such
有关更多信息,请查看此处Urllib2 文档
for more info look here Urllib2 Docs