How to download a file from an HTTP server given the URL?

Michel Claveau/Hamster supprimerAAAmc at AAAmclaveauPOINTcom.AAA
Thu Jun 17 12:13:47 EDT 2004


This sample run Ok on my windows :


def recupfileweb(adr, repenregistrement):
    data = urllib.urlopen(adr).read()
    list = string.split(adr,'/')
    nomlocal=list[-1]
    f = open(repenregistrement+nomlocal, "wb")
    f.write(data)
    f.close()
    print('Fichier '+repenregistrement+nomlocal+' téléchargé depuis '+adr)


recupfileweb("http://ponx.org/downloads/toto.zip","c:\\rdest\\")   #==>
C:\rdest\toto.zip







-- 
@-salutations
-- 
Michel Claveau
mél : http://cerbermail.com/?6J1TthIa8B
sites : http://mclaveau.com   http://bergoiata.org   http://ponx.org









More information about the Python-list mailing list