Edit Diskussion History Attachments

attachment:lw2txt.py of LarpWiki2Text

Attachment 'lw2txt.py'

Download

   1 #!/usr/bin/env python
   2 #
   3 # Tilmann Haak <spam@thaak.de>
   4 # 2011-12-04
   5 #
   6 # - Download all pages from larpwiki.de
   7 # - Write each page into a text file, e.g. "LarpWiki.txt"
   8 
   9 import xmlrpclib
  10 import time
  11 import string
  12 
  13 wiki = xmlrpclib.ServerProxy("http://www.larpwiki.de/?action=xmlrpc2")
  14 
  15 # get all pages on the wiki (sorted)
  16 pages = sorted(wiki.getAllPages())
  17 
  18 # dump pages to current dir
  19 count = 1
  20 for page in pages:
  21      pagename = page.encode('utf-8')
  22      filename = string.replace(pagename + '.txt', '/', '%2F')
  23      print("%i/%i %s" % (count, len(pages), filename))
  24      text = wiki.getPage(page).encode('utf-8')
  25      fd = open(filename, 'w')
  26      fd.write(text)
  27      fd.close()
  28      time.sleep(0.05) # don't hammer on the wiki!
  29      count += 1

New Attachment

File to upload
Rename to
Overwrite existing attachment of same name
Type: Foobar

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.
  • [get | view] (2011-12-15 23:52:05, 0.7 KB) [[attachment:lw2txt.py]]
  • [get | view] (2011-12-17 00:25:17, 1.7 KB) [[attachment:lw2txtV2.py]]
  • [get | view] (2012-12-25 18:49:40, 2.2 KB) [[attachment:lw2txtV3.py]]
  • [get | view] (2017-12-29 11:26:10, 8.1 KB) [[attachment:lw2txtV4.py]]
 All files | Selected Files: delete move to page copy to page