awss's notebooks

  • GSch ACPYPE citations - /awss/citations-acpype
    Last edited 3 years ago
    // Google Scholar search for the number of citations of a specific article title q = "ACPYPE - Antechamber python parser interface"; // use double-quotes for specific title y = "2012"; // restrict you search to a year const axios = require("axios").default; const keys = ["api_key0", "api_key1", "api_key"]; function set_url(key) { return `https://serpapi.com/search.json?engine=google_scholar&q='${q}'&as_ylo=${y}&as_yhi=${y}&hl=en&api_key=${process.env[key]}`; } function get_data(key) { return axios.get(set_url(key), {}); } for (const [i, key] of keys.entries()) { try { const { data } = await get_data(key); if (data) { const tot = data.organic_results[0].inline_links.cited_by.total; const obj = { schemaVersion: 1, label: "citations", message: tot.toString(), color: "orange", cacheSeconds: 2592000, }; exports.endpoint = function (request, response) { response.end(JSON.stringify(obj)); }; break; } } catch (error) {} }
  • GSch with SerpAPI - /awss/gsch-citations
    Last edited 3 years ago
    // 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)); };