-1

Goal: I have a list of links that link to a mp3 file which I would like to save to a directory.

Example: This is an example of a link that I stored in a list of python http://www.youtubeinmp3.com/download/get/?i=ydcYNJkoDxZhuV7x4neb4zcTaVJmCX9q&e=54

I tried using the requests module like so, however, this has not worked to save a file.

with open('static/'+url[url.rfind('/')+1:],'wb') as saved_file:
response = requests.get(mp3_url, stream=True)
if not response.ok:
    print("[-] Response did not return OK.")
for block in response.iter_content(1024):
    if not block:
        break
    saved_file.write(block)
  • define 'has not worked' ? and fix the indentation of the code. Important here. – Jean-François Fabre Jul 31 '17 at 19:39
  • 1
    If the link you provided is what your 'mp3_url' is, this will not work. The url is to the page which has the download link, not the mp3 url itself. You need 'mp3_url' to be of the url of the actual mp3 file. – TheoretiCAL Jul 31 '17 at 19:59

1 Answers1

0

I suggest you use selenium.

Then, for each youtube title you want to download you would:

Bill Bell
  • 21,021
  • 5
  • 43
  • 58