how to download internet files by python ?
MRAB
python at mrabarnett.plus.com
Tue Jan 8 10:19:49 EST 2013
On 2013-01-08 05:00, Rodrick Brown wrote:
> On Mon, Jan 7, 2013 at 11:19 PM, iMath <redstone-cold at 163.com
> <mailto:redstone-cold at 163.com>> wrote:
>
> for example ,if I want to download this file ,how to implement the
> download functionality by python ?
>
> http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3
>
> as for download speed ,of course ,the fast ,the better ,so how to
> implement it ?
>
> It would be better to show me an example :) thanks !!!
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
> #!/usr/bin/python
> import urllib2
> if __name__ == '__main__':
>
> fileurl='http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3'
>
> mp3file = urllib2.urlopen(fileurl)
> with open('outfile.mp3','wb') as output:
> output.write(mp3file.read())
>
Why not just use urlretrieve?
More information about the Python-list
mailing list