You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
938 B
Python
30 lines
938 B
Python
#https://gist.github.com/mjlavin80/186a6395c5819dbe25a8a0e001d5acfd
|
|
import requests
|
|
import json
|
|
|
|
|
|
|
|
# This script demonstrates how to query annotations for a particular URL using the hypothes.is API. An API key is required.
|
|
# The end result of this script is a Python dictionary with annotation data in it. Top save to csv or other format, further parsing would be required
|
|
def get_annotations():
|
|
KEY = "6879-GqSSbtmCoLUb8u9f6Gxh6DuScIkFKj321HSYzYZnjxc"
|
|
# here is the viewer pdf from each pdf
|
|
URL = "https://monoskop.org/Monoskop"
|
|
|
|
#a dictionary containing necessary http headers
|
|
headers = {
|
|
"Host": "hypothes.is",
|
|
"Accept": "application/json",
|
|
"Authorization": "Bearer %s" % KEY
|
|
}
|
|
|
|
base_url = "https://hypothes.is/api/search"
|
|
|
|
search_url = "".join([base_url, "?uri=", URL])
|
|
|
|
r = requests.get(search_url, headers=headers)
|
|
#data is a python dictionary
|
|
return json.loads(r.text)
|
|
|
|
|