Page MenuHomePhabricator
Paste P10689

random-page-title.py
ActivePublic

Authored by Xiplus on Thu, Mar 12, 12:34 PM.
import re
import requests
S = requests.Session()
URL = 'https://zh.wikivoyage.org/w/api.php'
PARAMS = {
'action': 'purge',
'titles': 'Wikivoyage:互助客栈',
'format': 'json'
}
cnt = 0
while True:
cnt += 1
# Get page title
req = requests.get('https://zh.wikivoyage.org/zh-tw/Wikivoyage:互助客栈')
html = req.text
m = re.search(r'<title>(.+?)</title>', html)
if m:
print(cnt, m.group(1))
# Purge page
R = S.post(url=URL, params=PARAMS)