Code

From Wizardsforge

Revision as of 00:53, 13 October 2006 by Brian (Talk | contribs)

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()
Personal tools