Skip to content

Instantly share code, notes, and snippets.

@bazuzu931
Last active February 14, 2017 17:44
Show Gist options
  • Save bazuzu931/42d84d3ddb1cd38f6dc7098d3a48c5bc to your computer and use it in GitHub Desktop.
Save bazuzu931/42d84d3ddb1cd38f6dc7098d3a48c5bc to your computer and use it in GitHub Desktop.
download_file(media,txt).py
import requests
def file_down(url):
r = requests.get(url, stream=True)
if r.status_code == requests.codes.ok: # requests.codes.ok == 200
with open("music.mp3", 'wb') as f:
f.write(r.content)
file_down("the_link_must_be_in_mp3_format.mp3") # example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment