]> projects.mako.cc - wikipedia-api-cdsw/blob - wikipedia-raw1.py
95e554d4751011b2f752cb13526e538f56c5d686
[wikipedia-api-cdsw] / wikipedia-raw1.py
1 import simplejson as json
2 from urllib2 import urlopen
3
4 wp_call = urlopen('https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Main_Page&rvlimit=100&rvprop=timestamp|user&format=json')
5
6 response = json.loads(wp_call.read())
7
8 for page_id in response["query"]["pages"].keys():
9     page_title = response["query"]["pages"][page_id]["title"]
10     revisions = response["query"]["pages"][page_id]["revisions"]
11
12     for rev in revisions:
13         print page_title + "\t" + rev["user"] + "\t" + rev["timestamp"]
14

Benjamin Mako Hill || Want to submit a patch?