Created
August 1, 2014 09:37
-
-
Save jalavik/6527af5edecd188a431e to your computer and use it in GitHub Desktop.
Playing with INSPIRE API
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
from invenio.invenio_connector import InvenioConnector | |
# 1. Connect to INSPIRE testing node | |
inspire = InvenioConnector(url="http://inspireheptest.cern.ch") | |
# 2. Do a search which returns a list of ids with the phrase "ellis" | |
res = inspire.search(p="ellis", of="intbitset") | |
# We asked for an intbitset, which is a comes over the wire as | |
# binary format - which means we convert it back to a proper intbitset | |
# structure on our end and cast to to a familiar list. | |
from invenio.intbitset import intbitset | |
results = list(intbitset(res)) | |
len(results) # returns now 3205 ids in a list. | |
# Get data from the first record as a json object | |
import json | |
record_as_json = inspire.search(recid=results[0], of="recjson") | |
record = json.loads(record_as_json) | |
print(record) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment