Code

From Wizardsforge

Revision as of 00:58, 13 October 2006 by Brian (Talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)

Python code to get a set of pages:

   import urllib
   
   def write_page(url, filename):
       sock = urllib.urlopen(url)
       htmlSource = sock.read()
       sock.close()
       
       save = open(filename, 'w')
       save.write(htmlSource)
       save.close()
       
   def write_page_list(list, path):
       index = open(path+'/index.txt', 'w')
       for x in range(0, len(list)):
           write_page(list[x], path+'/'+str(x)+'.html')
           index.write(str(x)+':'+list[x]+'\

')

       index.close()
   
   list = ['http://sfvlug.org','http://sfvlug.org/links.php','http://sfvlug.org/irc.php']
   
   write_page_list(list, 'testdir')


Make sure "testdir" exists.

Personal tools