rsshub
Version:
Make RSS Great Again!
58 lines (56 loc) • 1.85 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/bioone/featured.ts
const route = {
path: "/featured",
categories: ["journal"],
example: "/bioone/featured",
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["bioone.org/"] }],
name: "Featured articles",
maintainers: ["nczitzk"],
handler,
url: "bioone.org/"
};
async function handler(ctx) {
const rootUrl = "https://bioone.org";
const $ = load((await got_default(rootUrl, { https: { rejectUnauthorized: false } })).data);
let items = $(".items h4 a").slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 10).toArray().map((item) => {
item = $(item);
const link = item.attr("href").split("?")[0];
return {
title: item.text(),
link: link.includes("http") ? link : `${rootUrl}${link}`
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const content = load((await got_default(item.link, { https: { rejectUnauthorized: false } })).data);
item.description = content("#divARTICLECONTENTTop").html();
item.doi = content("meta[name=\"dc.Identifier\"]").attr("content");
item.pubDate = parseDate(content("meta[name=\"dc.Date\"]").attr("content"));
return item;
})));
return {
title: "Featured articles - BioOne",
link: rootUrl,
item: items
};
}
//#endregion
export { route };