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

Benjamin Mako Hill || Want to submit a patch?