0

I have a download link to a zip file. But I don't know how to use either wget or cURL from Python console to get it to my Downloads folder (OS X).

import os
os.system('wget {}'.format(results_url)

or

os.system('curl'.format(results_url)
512

none of these download the file.

Zlo
  • 1,150
  • 2
  • 18
  • 38
  • Hope these links helps. http://stackoverflow.com/questions/24346872/python-equivalent-of-a-given-wget-command and http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python – Tanmaya Meher Sep 08 '15 at 12:33
  • You could use the requests module which really makes this more simple, but if you want to use wget, you could use it with the subprocess module. subprocess.check_output(["wget", results_url]) gives you the output of wget – primero Sep 08 '15 at 12:34
  • The code works fine on my machine. What's the `results_url`? Are you sure the resource can be download? – luoluo Sep 08 '15 at 13:07
  • @luoluo that's the link – http://www.nexis.com/delivery/DownloadDoc.do?delFmt=QDS_EF_GENERICTYPE&fileSize=5000&dnldFilePath=%2Fl-n%2Fshared%2Fprod%2Fdiscus%2Fqds%2Frepository%2Fdocs%2F1%2F64%2F1826%3A528229641%2Fformatted_doc&zipDelivery=false&dnldFileName=European_News_in_English2015-09-08_15-15.TXT&jobHandle=1826%3A528229641 – Zlo Sep 08 '15 at 13:20

1 Answers1

0

The code and the link works fine on my machine. So I guess your results_url has wrong values. Or your network can't access the resources. You may try wget -v your_url to show the detail info of the request.

>>> import os
>>> os.system("wget http://www.nexis.com/delivery/DownloadDoc.do?delFmt=QDS_EF_GENERICTYPE&fileSize=5000&dnldFilePath=%2Fl-n%2Fshared%2Fprod%2Fdiscus%2Fqds%2Frepository%2Fdocs%2F1%2F64%2F1826%3A528229641%2Fformatted_doc&zipDelivery=false&dnldFileName=European_News_in_English2015-09-   08_15-15.TXT&jobHandle=1826%3A528229641")
0
>>> --2015-09-08 06:22:53--  http://www.nexis.com/delivery/DownloadDoc.do?delFmt=QDS_EF_GENERICTYPE
Resolving www.nexis.com (www.nexis.com)... 138.12.4.56
Connecting to www.nexis.com (www.nexis.com)|138.12.4.56|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: 鈥楧ownloadDoc.do?delFmt=QDS_EF_GENERICTYPE鈥

[   <=>                                                                                                       ] 13,217      20.9KB/s   in 0.6s   

2015-09-08 06:22:55 (20.9 KB/s) - 鈥楧ownloadDoc.do?delFmt=QDS_EF_GENERICTYPE鈥� saved [13217]

lo@ubuntu:~/aaa$ ll
total 24
drwxrwxr-x  2 lo lo  4096 Sep  8 06:22 ./
drwxr-xr-x 60 lo lo  4096 Sep  8 06:21 ../
-rw-rw-r--  1 lo lo 13217 Sep  8 06:22 DownloadDoc.do?delFmt=QDS_EF_GENERICTYPE
luoluo
  • 5,353
  • 3
  • 30
  • 41