Re: how to download internet files by python ?

2013-01-09 Thread iMath
在 2013年1月8日星期二UTC+8下午1时04分54秒,Roy Smith写道:
 In article mailman.259.1357620254.2939.python-l...@python.org,
 
  Cameron Simpson c...@zip.com.au wrote:
 
 
 
  On 07Jan2013 20:19, iMath redstone-c...@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 !!!
 
  
 
  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.

There is also a httplib2 module 
https://code.google.com/p/httplib2/

which one is more pythonic and powerful ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to download internet files by python ?

2013-01-09 Thread Tim Roberts
iMath redstone-c...@163.com wrote:

There is also a httplib2 module 
https://code.google.com/p/httplib2/

which one is more pythonic and powerful ?

Both are Pythonic, and power is irrelevant for this.  Your code is going to
spend 90% of its time waiting for the network.  Just solve the problem.
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to download internet files by python ?

2013-01-08 Thread MRAB

On 2013-01-08 05:00, Rodrick Brown wrote:

On Mon, Jan 7, 2013 at 11:19 PM, iMath redstone-c...@163.com
mailto:redstone-c...@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?
--
http://mail.python.org/mailman/listinfo/python-list


how to download internet files by python ?

2013-01-07 Thread iMath
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


Re: how to download internet files by python ?

2013-01-07 Thread Cameron Simpson
On 07Jan2013 20:19, iMath redstone-c...@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 !!!

Look at urllib2.
-- 
Cameron Simpson c...@zip.com.au

If God had intended Man to fly, He would have given him more money.
- Jeff Cauhape, cauh...@twg.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to download internet files by python ?

2013-01-07 Thread Rodrick Brown
On Mon, Jan 7, 2013 at 11:19 PM, iMath redstone-c...@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())
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to download internet files by python ?

2013-01-07 Thread Roy Smith
In article mailman.259.1357620254.2939.python-l...@python.org,
 Cameron Simpson c...@zip.com.au wrote:

 On 07Jan2013 20:19, iMath redstone-c...@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 !!!
 
 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.
-- 
http://mail.python.org/mailman/listinfo/python-list