How to download mp3 file on pc using python3 and saving it in a specific directory with random name having .mp3 extention ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to download mp3 file on pc using python3 and saving it in a specific directory with random name having .mp3 extention ?

file source : www.xyz.com/django.mp3 the below code helps to save mp3 in the same folder after download but what if i wanna save it to a specific directory on my pc 👇👇👇👇👇👇👇👇👇👇👇👇👇 https://code.sololearn.com/c22a0FPv0Msc/?ref=app

23rd Jul 2017, 4:43 PM
Pyrizard 🌟
Pyrizard 🌟 - avatar
2 Answers
+ 3
Download from where?... Skipping all the other obvious questions, do you just want someone to write the entire code for you? Start writing it yourself and when you encounter a problem you cant solve post the code (:
23rd Jul 2017, 6:23 PM
Maya
Maya - avatar
+ 3
You can do it by two ways... Your attempt try to use 'requests' module in a wrong way (as well for save the file than for generate a random name ^^)... which isn't always default installed (require to install through pip, or 'sudo apt-get install python3-requests' will work on Debian based systems): you can also do it with the 'urllib.request' module, which seems default available (at least in mine different configurations ;P)... for more compatibility ('requests' module import seems buggy on android QPython3 environment -- needs to comment import line :( but 'urllib' works ;)) https://code.sololearn.com/cRlHRWyOrj64/#py
24th Jul 2017, 6:25 AM
visph
visph - avatar