Domanda

Download usando wget in Python3.4

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

Guendo questo tipo di errore: -

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
.

È stato utile?

Soluzione

Il nome file non può essere ritornato tramite l'URL, né le intestazioni HTTP.Suggerirei di impostare il nome file di uscita te stesso:

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top