Attachment 'gettiki_html.py'
Download 1 #!/usr/local/bin/python
2
3 """
4 get wiki pages from a tikiwiki
5 Author: Daniela Nicklas
6 """
7 import sys
8 import httplib
9 from HTMLParser import HTMLParser
10 import string
11 import os
12
13 # config variables
14
15 wikihost="hostname"
16 wikipath="/tiki/tiki-print.php?page="
17 targetdir="pages"
18 pagelistfile = "pagelist"
19
20
21 # global variables
22 wikiroot = "" # root for all wiki pages
23 pagelist = [] # list of all wiki pages
24
25 # get pagelist
26 pl = open(pagelistfile,'r')
27 pagelist = []
28 for line in pl:
29 pagelist.append(line.strip())
30 pl.close
31
32 print "Dumping Wiki %s to directory %s"%(wikihost,targetdir)
33
34 # create directory (if necessary)
35 if not os.access(targetdir, os.F_OK):
36 os.mkdir(targetdir)
37
38 # open connection and get the titleindex
39 httpconnection = httplib.HTTPConnection(wikihost)
40
41 # fetch pages
42 for pagename in pagelist:
43 httpconnection.request("GET", wikipath+pagename)
44 response = httpconnection.getresponse()
45 if response.status != 200:
46 print response.status, response.reason
47 else:
48 # get pages
49 print pagename
50 pagetext = response.read()
51 f = open(targetdir+"/"+pagename+".html", "w")
52 f.write(pagetext)
53 f.close()
54
55 # close the connection
56 httpconnection.close()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.