Question

downloading using wget in python3.4

import wget
url = "http://api.example.com/tracks/41078914/stream?client_id=d97babdd9960f87d30831e0eb9d"
file = wget.download(url)
print(file)

geting this type of error:-

Traceback (most recent call last):
File "/home/poison/PycharmProjects/pytho_pro/B1.py", line 10, in <module>
file = wget.download(url)
File "/usr/local/lib/python3.4/dist-packages/wget.py", line 319, in download
filename = filename_fix_existing(filename)
File "/usr/local/lib/python3.4/dist-packages/wget.py", line 77, in filename_fix_existing
name, ext = filename.rsplit('.', 1)
ValueError: need more than 1 value to unpack
Was it helpful?

Solution

The filename could not be retreived through the url, nor the HTTP headers. I would suggest setting the output filename yourself:

import wget
url = "http://api.example.com/tracks/41078914/stream?client_id=d97babdd9960f87d30831e0eb9d"
file = wget.download(url,out="myFile.mp3")
print(file)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top