]> projects.mako.cc - wikipedia-api-cdsw/blob - wikipedia-raw2.py
c7eca1be4f72a90bd8a03bdc11b80fa22db2932d
[wikipedia-api-cdsw] / wikipedia-raw2.py
1 import time
2 import simplejson as json
3 from urllib2 import urlopen
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 = urlopen(url_base % page_title)
12     response = json.loads(wp_call.read())
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?