UNPKG

rsshub

Version:
57 lines (55 loc) 1.58 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { i as getArticleList, n as cookieJar, r as getArticle, t as baseUrl } from "./utils-9e_EwON4.mjs"; import { load } from "cheerio"; //#region lib/routes/nature/highlight.ts const route = { path: "/highlight/:journal?", categories: ["journal"], example: "/nature/highlight", parameters: { journal: "short name for a journal, `nature` by default" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: true }, radar: [{ source: [ "nature.com/:journal/articles", "nature.com/:journal", "nature.com/" ], target: "/highlight/:journal" }], name: "Research Highlight", maintainers: [], handler, description: `::: warning Only some journals are supported. :::` }; async function handler(ctx) { const { journal = "nature" } = ctx.req.param(); const url = `${baseUrl}/${journal}/articles?type=research-highlight`; const $ = load((await got_default(url, { cookieJar })).data); let items = getArticleList($); items = await Promise.all(items.map((item) => getArticle(item))); return { title: $("title").text().trim(), description: $("meta[name=description]").attr("content"), link: url, item: items }; } //#endregion export { route };