From 426889e00dc92633bc5d90d5258903f52cc00922 Mon Sep 17 00:00:00 2001 From: Michael Murtaugh Date: Wed, 1 Apr 2020 19:50:34 +0200 Subject: [PATCH] filenameforhref --- dumpwiki.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dumpwiki.py b/dumpwiki.py index 1a97ef0..4635c2d 100644 --- a/dumpwiki.py +++ b/dumpwiki.py @@ -36,6 +36,12 @@ def filenameforpage(p): f = p.name.replace(' ','_').replace('/', SLASH) + '.html' return f +def filenameforlink(href): + if href.startswith("/sandbox/itchwiki/index.php/"): + href = href[len("/sandbox/itchwiki/index.php/"):] + return href.replace(' ','_').replace('/', SLASH) + '.html' + return href + def rewritelinks (html): t = html5lib.parseFragment(html, treebuilder = "etree", namespaceHTMLElements = False) for a in t.findall(".//*[@href]"):