how to download internet files by python ?

R

Rodrick Brown

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 !!!

#!/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())
 
R

Roy Smith

Cameron Simpson said:
| 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 !!!

Look at urllib2.

Even better, look at requests
(http://docs.python-requests.org/en/latest/). There's nothing you can
do with requests that you can't do with urllib2, but the interface is a
whole lot easier to work with.
 
M

MRAB

On Mon, Jan 7, 2013 at 11:19 PM, iMath <[email protected]

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top