Python Forum

Full Version: get file by proxy and header using urllib.request.urlretrieve
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
url = "https://url"

proxy = urllib.request.ProxyHandler({'https': 'https://proxy'})
opr = urllib.request.build_opener(proxy)
urllib.request.install_opener(opr)

opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla')]
urllib.request.install_opener(opener)
urllib.request.urlretrieve(url, "name")

its connecting by proxy but refuse to collect header any way to get file with both proxy and geader plz....