#!/usr/bin/env python # Currently only tested with Python3 from __future__ import print_function import os import sys import json import argparse import requests import urllib.parse import util apiKey = util.readKey("oacore-key.txt") # Example DOI from CORE v3 API: # https://api.core.ac.uk/docs/v3#operation/null # (scroll down to Discovery) # oacore_doi="10.1016/0370-2693(96)00910-0" # Bainbridge et al example, IJDL user-centric approach ... stinky_doi="10.1145/1998076.1998084" print("Selecting Core example DOI: " + oacore_doi) doi = oacore_doi # Based on: # https://stackoverflow.com/questions/25491090/how-to-use-python-to-execute-a-curl-command base_url = "https://api.core.ac.uk/v3" search_work_url = base_url+"/search/works/" discover_url = base_url+"/discover" headers = { 'Content-type': 'application/json' } query_args = "api_key="+apiKey+"&q="+urllib.parse.quote_plus("doi:\""+doi+"\"") query_url = search_work_url + "?" + query_args print("query_url="+query_url) response = requests.get(query_url, headers=headers) #data = '{}' # More work to be done to see if the following can be made to work #data = { # "api_key": apiKey, # "q": "doi:\""+doi+"\"" #} #response = requests.get(query_url, headers=headers, data=data) returned_json_str = response.content returned_json = json.loads(returned_json_str) returned_json_prettyprint = json.dumps(returned_json, indent=2) print(returned_json_prettyprint) # Or consider using their Python API: # # https://github.com/oacore/pyoacore # They also support Java, R and (it looks like) NodeJS # https://core.ac.uk/search?q=doi%3A%2210.1186%2F1471-2458-6-309%22&page=1