def downImg(url,filepath): urllib.urlretrieve(url, filepath) def url_build_proxy_opener(proxy_info): passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() passmgr.add_password(None, proxy_info['server'] , proxy_info['user'], proxy_info['password']) auth = urllib2.ProxyBasicAuthHandler(passmgr) opener = urllib2.build_opener(urllib2.ProxyHandler({'http':proxy_info['server']}) , auth) return opener
urllib.urlretrieve()函数有时候不顶用,具体原因未知。