Script and cover and readme
commit
949725c92d
Binary file not shown.
After Width: | Height: | Size: 130 KiB |
@ -0,0 +1,37 @@
|
|||||||
|
# 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'])
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
# Almanac
|
||||||
|
|
||||||
|
![cover with ancient 3d book and the pzi wiki logo and homepage](almanac.jpg)
|
||||||
|
|
||||||
|
Python script that connect to the PZI Media Wiki API and compile a list with the title of all the pages.
|
||||||
|
|
||||||
|
To run:
|
||||||
|
|
||||||
|
```
|
||||||
|
python3 almanac.py
|
||||||
|
```
|
||||||
|
|
||||||
|
It's going to save the list in alphabetic order into the `list.txt` file.
|
Loading…
Reference in New Issue