|
A file downloader in Python |
|
|
|
|
Programming -
Python
|
|
Here is a code to download a file and write it into a file. this code can download anyfile irrespective of the it’s type. It downloads the file specified in URL and saves it as File.pdf.
from sgmllib import SGMLParser
class Crawler(SGMLParser): def reset(self): SGMLParser.reset(self) self.URL = "http://somesite.com/resume.pdf" self.ReterievedFile = "File.pdf"
if __name__ == "__main__": import urllib parser = Crawler()
try: usock = urllib.urlretrieve(self.URL,parser.ReterievedFile) except IOError: print "error"
parser.close() |
|
Last Updated on Sunday, 28 March 2010 07:24 |