Skip to content

Instantly share code, notes, and snippets.

@PythonCoderUnicorn
Created March 24, 2023 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PythonCoderUnicorn/dd0006a51830e16d76185c700fb22d49 to your computer and use it in GitHub Desktop.
Save PythonCoderUnicorn/dd0006a51830e16d76185c700fb22d49 to your computer and use it in GitHub Desktop.

download .mp3 from internet

R language

url = "website/audio/song.mp3"

# add song_name.mp3 or it won't work
local_path = "directory/path/song_name.mp3" 

download.file(url, local_path)

Python

def download( url:str):
    from requests import get 
    import random 

    name = random.randint(1, 1001)
    file_name = str(name) + ".mp3"

    with open( file_name, "wb") as file:
        response = get(url)
        file.write(response.content)

download(url = "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment