#1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155

    Download from the Internet


    Can anyone show me how to do a simple download through Python? Maybe one that won't show any windows, it will download a certain file into a designated directory.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    The easiest way to do this is to use the urllib/urllib2 modules open() function to read the file from the internet. You can then write this data to a local file like you would any other string.

    http://www.python.org/doc/2.4/lib/module-urllib.html
    http://www.python.org/doc/2.4/lib/module-urllib2.html

    Note: if the file is binary (an image) you need to use the 'wb' flag when opening your file rather than 'w'.

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo