1

I try to download a tgz file from an url. If I use the link and copy it to Firefox, a download-as dialog occures and I can download the data.

If I use this code, I get an urlopen error:

urllib.request.urlretrieve(HOUSING_URL, "C:/HomeC/data.tgz")

Does anybody know, what I'm doing wrong? Again: The link, stored in HOUSING_URL is correct and working in a browser. There are also no mistakes by typing it, as I copy the path directly from the "Watch window" in Visual Studio

Jan021981
  • 521
  • 3
  • 28

2 Answers2

0

Do you have any proxies setup? You could try this -

image = urllib.URLopener(proxies={})
image.retrieve(HOUSING_URL, "C:/HomeC/data.tgz")

You can check these too Using an HTTP PROXY - Python

Vivek
  • 322
  • 1
  • 13
0

you can add these code before retrieve data

# set proxy
proxy = urllib.request.ProxyHandler({"https":"http://your proxy IP:port"})
opener = urllib.request.build_opener(proxy)
urllib.request.install_opener(opener)

urllib.request.retrieve(housing_url, tgz_path)
...
Plutors
  • 72
  • 1
  • 9