Programming

(Python) How do I download a file over HTTP using Python?

steloflute 2012. 6. 19. 11:21
http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python

 

import urllib
response
= urllib.urlopen('http://www.example.com/sound.mp3')
mp3
= response.read()

Will work fine. Or, if you don't want to deal with the "response" object you can call read() directly:

import urllib 
mp3 = urllib.urlopen('http://www.example.com/sound.mp3').read()