]> projects.mako.cc - wikipedia-api-cdsw/blob - wikipedia2-1.py
3cb23d93752386b9ecf256c8d8fa872d8939a263
[wikipedia-api-cdsw] / wikipedia2-1.py
1 import requests
2
3 url_base = 'https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=%s&rvlimit=100&rvprop=timestamp|user&continue=&format=json'
4
5 pages = ["Benjamin Mako Hill", "Python", "Data science"]
6
7 for page_title in pages:
8     
9     wp_call = requests.get(url_base % page_title)
10     response = wp_call.json()
11
12     for page_id in response["query"]["pages"].keys():
13         page_title = response["query"]["pages"][page_id]["title"]
14         revisions = response["query"]["pages"][page_id]["revisions"]
15
16         for rev in revisions:
17             print(page_title + "\t" + rev["user"] + "\t" + rev["timestamp"])
18

Benjamin Mako Hill || Want to submit a patch?