Pergunta

o download usando o wget em python3.4

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

geting esse tipo de erro:-

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
Foi útil?

Solução

O nome do arquivo não pôde ser recuperados através de uma url, nem os cabeçalhos de HTTP.Gostaria de sugerir a definição do nome do arquivo de saída a si mesmo:

import wget
url = "http://api.example.com/tracks/41078914/stream?client_id=d97babdd9960f87d30831e0eb9d"
file = wget.download(url,out="myFile.mp3")
print(file)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top