how to download internet files by python ?

Discussion in 'Python' started by iMath, Jan 8, 2013.

  1. iMath

    iMath Guest

    iMath, Jan 8, 2013
    #1
    1. Advertising

  2. On 07Jan2013 20:19, iMath <> 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 <>

    If God had intended Man to fly, He would have given him more money.
    - Jeff Cauhape,
    Cameron Simpson, Jan 8, 2013
    #2
    1. Advertising

  3. On Mon, Jan 7, 2013 at 11:19 PM, iMath <> 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())
    Rodrick Brown, Jan 8, 2013
    #3
  4. iMath

    Roy Smith Guest

    In article <>,
    Cameron Simpson <> wrote:

    > On 07Jan2013 20:19, iMath <> 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.
    Roy Smith, Jan 8, 2013
    #4
  5. iMath

    MRAB Guest

    On 2013-01-08 05:00, Rodrick Brown wrote:
    > On Mon, Jan 7, 2013 at 11:19 PM, iMath <
    > <mailto:>> 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?
    MRAB, Jan 8, 2013
    #5
  6. iMath

    iMath Guest

    在 2013å¹´1月8日星期二UTC+8下åˆ1æ—¶04分54秒,Roy Smith写é“:
    > In article <>,
    >
    > Cameron Simpson <> wrote:
    >
    >
    >
    > > On 07Jan2013 20:19, iMath <> 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 ?
    iMath, Jan 10, 2013
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Norton
    Replies:
    6
    Views:
    1,872
    Norton
    Jun 10, 2004
  2. cmay
    Replies:
    0
    Views:
    1,115
  3. Katie Wright
    Replies:
    8
    Views:
    4,206
    Andrea Desole
    Jan 7, 2005
  4. Replies:
    5
    Views:
    739
    Juan T. Llibre
    Jan 26, 2007
  5. John Smith
    Replies:
    1
    Views:
    130
    Evertjan.
    Mar 12, 2005
Loading...

Share This Page