Skip to content

Instantly share code, notes, and snippets.

@bram-atmire
Last active July 16, 2019 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bram-atmire/52fe162554504b4e1471a17773d9447c to your computer and use it in GitHub Desktop.
Save bram-atmire/52fe162554504b4e1471a17773d9447c to your computer and use it in GitHub Desktop.
DSpace helper Google Apps Script to retrieve full text from CORE discovery
function onOpen() {
SpreadsheetApp.getUi().createMenu("Atmire")
.addItem('Find Full Text','findFullText')
.addToUi();
}
function findFullText() {
var yourapikey = "REPLACEWITHYOURAPIKEY";
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var numrows = sheet.getLastRow()+1;
for( x=2 ; x<numrows ; x++){
var doi = sheet.getRange("C"+x).getValue();
if (doi){
var url = 'https://api.core.ac.uk/discovery/discover?doi='+doi+'&apiKey='+yourapikey;
var options = {
'method' : 'get',
'contentType': 'application/json',
};
var response = UrlFetchApp.fetch(url, options);
var json = response.getContentText();
var resultdata = JSON.parse(json);
sheet.getRange("D"+x).setValue(resultdata.source);
var encodedURI = resultdata.fullTextLink.substring(48);
sheet.getRange("E"+x).setValue(decodeURIComponent(encodedURI));
Utilities.sleep(1000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment