"Timo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
What is the best/correct way to download files from a webpage?

www.example.com/example.mp3 for instance.

I know how to open the site (with urllib), but have no idea how to write the file to the harddisk.

Quick and dirty, if example.mp3 isn't too big to fit in memory at once:

import urllib
fin = urllib.urlopen('http://www.example.com/example.mp3')
fout = open('example.mp3','wb')
fout.write(fin.read())
fin.close()
fout.close()

-Mark


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to