UNPKG

rsshub

Version:
58 lines (56 loc) 1.63 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { n as cookieJar, r as getArticle, t as baseUrl } from "./utils-9e_EwON4.mjs"; import { load } from "cheerio"; //#region lib/routes/nature/news.ts const route = { path: "/news", categories: ["journal"], example: "/nature/news", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: true }, radar: [{ source: [ "nature.com/latest-news", "nature.com/news", "nature.com/" ] }], name: "Nature News", maintainers: ["y9c", "TonyRL"], handler, url: "nature.com/latest-news" }; async function handler() { const url = `${baseUrl}/latest-news`; const $ = load((await got_default(url, { cookieJar })).data); let items = $(".c-article-item__content").toArray().map((item) => { item = $(item); return { title: item.find("h3").text(), link: baseUrl + item.find("a").attr("href"), pubDate: parseDate(item.find(".c-article-item__date").text()) }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, () => getArticle(item)))); return { title: "Nature | Latest News", description: $("meta[name=description]").attr("content"), link: url, item: items }; } //#endregion export { route };