help="index template file", ) optParser.add_option("-r", "--version", help="add version info") (options, args) = optParser.parse_args() try: os.mkdir(options.mirror) except: pass try: os.mkdir(options.mirror + "/images") except: pass images = set() if len(args) == 0: p = readParsePage("Special:AllPages") p = p[p.find('<input type="submit" value="Go" />') :] p = p[p.find("<table ") :] pages = p.split("<a ") else: pages = ['href="/wiki/%s"' % a for a in args] for p in pages: if not p.startswith("href"): continue b = p.find("/wiki/") e = p.find('"', b) name = p[b + 6 : e] if name.endswith(".css"): print "Skipping css-file %s" % name continue print "Fetching %s" % name
"..", "docs", "wiki", "index.html"), help="index template file") optParser.add_option("-r", "--version", help="add version info") (options, args) = optParser.parse_args() try: os.mkdir(options.mirror) except: pass try: os.mkdir(options.mirror + "/images") except: pass images = set() if len(args) == 0: p = readParsePage("Special:AllPages") p = p[p.find('<ul class="mw-allpages-chunk">'):] pages = p.split("<a ") else: pages = ['href="/wiki/%s"' % a for a in args] for p in pages: if not p.startswith("href"): continue b = p.find("/wiki/") e = p.find("\"", b) name = p[b + 6:e] if name.endswith(".css"): print("Skipping css-file %s" % name) continue print("Fetching %s" % name) c = readParsePage(name)
try: os.mkdir(options.mirror) except Exception: pass try: os.mkdir(options.mirror + "/images") except Exception: pass images = set() pages = getAllPages(args) for name in pages: if name.endswith(".css"): print("Skipping css-file %s" % name) continue print("Fetching %s" % name) c = readParsePage(name) if name.find("/") > 0: try: os.makedirs(os.path.join(options.mirror, name[:name.rfind("/")])) except Exception: pass if True: # name.find(".")<0: c, pi, level = patchLinks(c, name) for i in pi: images.add(i) c, pi = patchImages(c, name) for i in pi: images.add(i) name = name + ".html" fd = open(os.path.join(options.mirror, name), "wb") fd.write(c.encode("utf8"))