Skip to content

Instantly share code, notes, and snippets.

@eyeseast
Created May 23, 2010 04:11
Show Gist options
  • Save eyeseast/410627 to your computer and use it in GitHub Desktop.
Save eyeseast/410627 to your computer and use it in GitHub Desktop.
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