Code
From Wizardsforge
(Difference between revisions)
Line 19: | Line 19: | ||
') | ') | ||
index.close() | 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. |
Current revision as of 00:58, 13 October 2006
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.