You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
# from urllib import request
|
|
import requests
|
|
from pprint import pprint
|
|
|
|
|
|
import ssl
|
|
ssl._create_default_https_context = ssl._create_unverified_context
|
|
|
|
def query(request):
|
|
request['action'] = 'query'
|
|
request['format'] = 'json'
|
|
lastContinue = {}
|
|
while True:
|
|
# Clone original request
|
|
req = request.copy()
|
|
# Modify it with the values returned in the 'continue' section of the last result.
|
|
req.update(lastContinue)
|
|
# Call API
|
|
result = requests.get('https://pzwiki.wdka.nl/mw-mediadesign/api.php', params=req).json()
|
|
if 'error' in result:
|
|
raise Error(result['error'])
|
|
if 'warnings' in result:
|
|
print(result['warnings'])
|
|
if 'query' in result:
|
|
yield result['query']
|
|
if 'continue' not in result:
|
|
break
|
|
lastContinue = result['continue']
|
|
|
|
|
|
if __name__ == '__main__':
|
|
for result in query({'generator': 'allpages'}):
|
|
pprint(result)
|
|
with open('list.txt', 'a') as f:
|
|
for key, value in result['pages'].items():
|
|
f.writelines([value['title'], '\n'])
|
|
|