Varia library working group XPPL. https://gitea.xpub.nl/XPUB/XPPL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

7 years ago
#https://gist.github.com/mjlavin80/186a6395c5819dbe25a8a0e001d5acfd
import requests
import json
def get_annotations():
KEY = "6879-rwfbfodYqhBn2OK2ODnNGkzlWUa4bPCoJi2U8pgTYHg"
7 years ago
headers = {
"Host": "xppl",
7 years ago
"Accept": "application/json",
"Content-Type": "application/json",
7 years ago
"Authorization": "Bearer %s" % KEY
}
search_url = "".join("http://localhost:5000/api/search")
7 years ago
r = requests.get(search_url, headers=headers)
data = json.loads(r.text)
return data
# extract=[]
# for item in data['rows']:
# # if 'exact' in item['target'][0]['selector'][2]:
# if 'selector' in item['target'][0]:
# if len(item['target'][0]['selector']) > 2:
# extract.append('extract:' + (item['target'][0]['selector'][2]['exact']))
# extract.append('annotation:' + item['text'])
# extract.append ('-----------')
# else:
# extract.append('annotation:' + item['text'])
# extract.append ('-----------')
# return extract
7 years ago