#! /usr/bin/env python3 import os.path from ws.client import API api_url = "https://wiki.archlinux.org/api.php" cookie_path = os.path.expanduser("~/.cache/ArchWiki.cookie") api = API(api_url, cookie_file=cookie_path, ssl_verify=True) # allpages # see list of parameters: https://www.mediawiki.org/wiki/API:Allpages for page in api.generator(generator="allpages", gaplimit="max"): print(page["title"]) # allcategories # see list of parameters: https://www.mediawiki.org/wiki/API:Allcategories #for page in api.generator(generator="allcategories", gaclimit="max"): # print(page["title"]) # categorymembers # see list of parameters: https://www.mediawiki.org/wiki/API:Categorymembers #for page in api.generator(generator="categorymembers", gcmtitle="Category:English", gcmlimit="max"): # print(page["title"]) # transclusions # see list of parameters: https://www.mediawiki.org/wiki/API:Embeddedin #for page in api.generator(generator="embeddedin", geititle="Template:AUR", geilimit="max"): # print(page["title"])
#! /usr/bin/env python3 import os.path from collections import namedtuple import itertools from ws.client import API import ws.ArchWiki.lang as lang api_url = "https://wiki.archlinux.org/api.php" cookie_path = os.path.expanduser("~/.cache/ArchWiki.cookie") api = API(api_url, cookie_file=cookie_path, ssl_verify=True) Page = namedtuple("Page", ["title", "langname", "pure"]) pages = [] for page in api.generator(generator="allpages", gaplimit="max", gapfilterredir="nonredirects"): pure, langname = lang.detect_language(page["title"]) pages.append(Page(page["title"], langname, pure)) pages.sort(key=lambda page: (page.langname, page.pure)) groups = itertools.groupby(pages, key=lambda page: page.langname) for langname, pages in groups: print("== {} ==\n".format(langname)) for page in pages: print("* [[:{}|{}]]".format(page.title, page.pure)) print()
import os.path from collections import namedtuple import itertools from ws.client import API import ws.ArchWiki.lang as lang api_url = "https://wiki.archlinux.org/api.php" index_url = "https://wiki.arclinux.org/index.php" session = API.make_session() api = API(api_url, index_url, session) Page = namedtuple("Page", ["title", "langname", "pure"]) pages = [] for page in api.generator(generator="allpages", gaplimit="max", gapfilterredir="nonredirects"): pure, langname = lang.detect_language(page["title"]) pages.append(Page(page["title"], langname, pure)) pages.sort(key=lambda page: (page.langname, page.pure)) groups = itertools.groupby(pages, key=lambda page: page.langname) for langname, pages in groups: print("== {} ==\n".format(langname)) for page in pages: print("* [[:{}|{}]]".format(page.title, page.pure)) print()
#! /usr/bin/env python3 import os.path from ws.client import API api_urls = [ "https://wiki.archlinux.org/api.php", "https://wiki.archlinux.de/api.php", ] index_url = "https://wiki.arclinux.org/index.php" session = API.make_session() for api_url in api_urls: api = API(api_url, index_url, session) prefixes = set() for ns in api.site.namespaces: if ns < 0: continue for page in api.generator(generator="allpages", gaplimit="max", gapfilterredir="nonredirects", gapnamespace=ns, prop="iwlinks", iwprop="url", iwlimit="max"): for link in page.get("iwlinks", []): prefixes.add(link["prefix"]) print("interwiki prefixes used on {}:".format(api.get_hostname())) print(sorted(prefixes))
#! /usr/bin/env python3 import os.path from ws.client import API api_urls = [ "https://wiki.archlinux.org/api.php", "https://wiki.archlinux.de/api.php", ] cookie_path = os.path.expanduser("~/.cache/ArchWiki.cookie") for api_url in api_urls: api = API(api_url, cookie_file=cookie_path, ssl_verify=True) prefixes = set() for ns in api.site.namespaces: if ns < 0: continue for page in api.generator(generator="allpages", gaplimit="max", gapfilterredir="nonredirects", gapnamespace=ns, prop="iwlinks", iwprop="url", iwlimit="max"): for link in page.get("iwlinks", []): prefixes.add(link["prefix"]) print("interwiki prefixes used on {}:".format(api.get_hostname())) print(sorted(prefixes))