Skip to content

Instantly share code, notes, and snippets.

@agusmakmun
Created May 2, 2015 16:26
Show Gist options
  • Save agusmakmun/b7fa7c28c6a7394593eb to your computer and use it in GitHub Desktop.
Save agusmakmun/b7fa7c28c6a7394593eb to your computer and use it in GitHub Desktop.
Simple Download Python
>>> import urllib
>>> testfile = urllib.URLopener()
>>> testfile.retrieve("http://mpsound.ga/uploads/tracks/1721469648_2006899744_556355825.mp3", "sample123.mp3")
('sample123.mp3', <httplib.HTTPMessage instance at 0xb6e4984c>)
>>>
import urllib2
url = "http://translate.google.com/translate_tts?tl=en&q=text"
request = urllib2.Request(url)
request.add_header('User-agent', 'Mozilla/5.0')
opener = urllib2.build_opener()
f = open("data.mp3", "wb")
f.write(opener.open(request).read())
f.close()
$ sudo pip install wget
>>> import wget
>>> url = 'http://www.futurecrew.com/skaven/song_files/mp3/razorback.mp3'
>>> filename = wget.download(url)
100% [......................................................] 3841532 / 3841532>>> filename
'razorback (3).mp3'
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment