Created
May 23, 2010 04:11
-
-
Save eyeseast/410627 to your computer and use it in GitHub Desktop.
This file contains 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 urllib, urllib2 | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
BASE_URL = "http://www.documentcloud.org/api/search.json?" | |
def search(q, page=1, sections=False, annotations=False): | |
""" | |
Search for documents on DocumentCloud | |
""" | |
params = { | |
'q': q, | |
'page': page, | |
'sections': sections, | |
'annotations': annotations | |
} | |
url = BASE_URL + urllib.urlencode(params) | |
response = urllib2.urlopen(url) | |
return json.loads(response.read())['documents'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment