Created
June 3, 2014 00:57
-
-
Save cbare/1093d566354bebc04daa to your computer and use it in GitHub Desktop.
Retrieve the last 100 revisions of a wikipedia article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import synapseclient | |
| from synapseclient import File, Project, Folder | |
| syn = synapseclient.login() | |
| ## get latest 100 revisions of a wikipedia article | |
| url = "http://en.wikipedia.org/w/api.php?action=query&titles=Crimea&prop=revisions&rvprop=ids|timestamp|flags|content&rvlimit=100&format=json" | |
| response = requests.get(url) | |
| crimea = response.json() | |
| ## make sure we got 100 | |
| print len(crimea['query']['pages']['163045']['revisions']) | |
| ## write to a file | |
| with open('crimea.revisions.json', 'w') as f: | |
| json.dump(crimea, f) | |
| project = syn.get('syn2489903') | |
| ## store in Synapse | |
| syn.store(File('crimea.revisions.json', parent=project)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment