User:Emojiwiki/Share/mediawiki ns.py
外观
< User:Emojiwiki | Share
import requests from bs4 import BeautifulSoup as bs
api_where = str(input('What is the mediawiki site url?(no https://,etc): '))
url = 'https://' + api_where + '/w/api.php?action=query&format=xml&meta=siteinfo&siprop=namespacealiases'
xml = requests.get(url).text sp = bs(xml, 'html.parser') id_count = 0 while id_count != 3000:
id_count = id_count + 1 ns_data = sp.find_all('ns', {'id':id_count}) if len(ns_data) > 0: print(id_count,end=': ') for name in ns_data: name_show = [name] print(name_show[0].text,end=' / ') print()