Created
April 29, 2015 22:35
-
-
Save judell/f794f719a5240de9f939 to your computer and use it in GitHub Desktop.
all annotations
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 json, urllib2, re | |
offset = 0 | |
limit = 200 | |
more = True | |
def search(): | |
global offset, limit, more | |
h_url = 'https://hypothes.is/api/search?limit=%d&offset=%d' % ( limit, offset) | |
s = urllib2.urlopen(h_url).read() | |
j = json.loads(s) | |
rows = j['rows'] | |
if len(rows): | |
for row in rows: | |
yield row | |
offset += limit | |
else: | |
more = False | |
rows = [] | |
while more: | |
for row in search(): | |
rows.append(row) | |
s = json.dumps(rows) | |
f = open('c:\\users\\jon\\all_annos.json','w') | |
f.write(s) | |
f.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment