UNPKG

rsshub

Version:
65 lines (62 loc) 2.25 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/google/citations.ts const route = { path: "/citations/:id", categories: ["journal"], example: "/google/citations/mlmE4JMAAAAJ", parameters: { id: "N" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, name: "Scholar Author Citations", maintainers: ["KellyHwong", "const7"], handler, description: `The parameter id in the route is the id in the URL of the user's Google Scholar reference page, for example \`https://scholar.google.com/citations?user=mlmE4JMAAAAJ\` to \`mlmE4JMAAAAJ\`. Query parameters are also supported here, for example \`https://scholar.google.com/citations?user=mlmE4JMAAAAJ&sortby=pubdate\` to \`mlmE4JMAAAAJ&sortby=pubdate\`. Please make sure that the user id (\`mlmE4JMAAAAJ\` in this case) should be the first parameter in the query string.` }; async function handler(ctx) { const id = ctx.req.param("id"); const BASE_URL = `https://scholar.google.com`; const url = `https://scholar.google.com/citations?user=${id}`; const $ = load((await got_default({ method: "get", url })).data); const profile = $("#gsc_prf .gsc_prf_il").eq(0).text(); const homePage = $("#gsc_prf_ivh a").attr("href"); const name = $("#gsc_prf_in").text(); const description = `Google Scholar Citation Monitor: ${name}; Profile: ${profile}; HomePage: ${homePage}`; const out = $("#gsc_a_b .gsc_a_tr").toArray().map((item) => { const $$1 = load(item); const itemUrl = BASE_URL + $$1(".gsc_a_t a").attr("href"); const author = $$1(".gsc_a_t div").eq(0).text(); const publication = $$1(".gsc_a_t div").eq(1).text(); return { title: $$1(".gsc_a_t a").text(), author, description: `Author: ${author}; Publication: ${publication}`, link: itemUrl, guid: itemUrl }; }); return { title: `Google Scholar: ${name}`, link: url, description, item: out }; } //#endregion export { route };