Python Forum
get file by proxy and header using urllib.request.urlretrieve - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: get file by proxy and header using urllib.request.urlretrieve (/thread-24953.html)



get file by proxy and header using urllib.request.urlretrieve - randyjack - Mar-12-2020

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....