rsshub
Version:
Make RSS Great Again!
51 lines (50 loc) • 1.58 kB
JavaScript
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs";
import { t as cache_default } from "./cache-BkqOokyU.mjs";
import { t as got_default } from "./got-BTowW50G.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)).data);
let items = $(".items h4 a").slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 10).toArray().map((item) => {
const $item = $(item);
const link = $item.attr("href").split("?", 1)[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)).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 };