// Google Scholar search for the number of citations of a specific article title
let params = {
engine: "google_scholar",
as_ylo: "2012", // restrict you search to a year
as_yhi: "2012", // restrict you search to a year
q: '"ACPYPE-Antechamber python parser interface"', // use double-quotes for specific title
hl: "en",
// there are several other parameters for refining a query
};
const SerpApi = require('google-search-results-nodejs');
const search = new SerpApi.GoogleSearch(process.env.api_key);
function promisifiedGetJson(params) {
return new Promise((resolve, reject) => {
try {
search.json(params, resolve)
} catch (e) {
reject(e)
}
})
}
async function main(params) {
try {
const data = await promisifiedGetJson(params);
const total = data.organic_results[0].inline_links.cited_by.total;
return total;
} catch (error) {
console.error("there was an error:", error);
}
}
const tot = await main(params);
const obj = { "schemaVersion": 1, "label": "citations", "message": tot.toString(), "color": "orange", "cacheSeconds": 2592000 };
exports.endpoint = function (request, response) {
response.end(JSON.stringify(obj));
};