UNPKG

rsshub

Version:
70 lines (67 loc) 3.17 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import "./render-BQo6B4tL.mjs"; import "./proxy-Db7uGcYb.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { n as puppeteer_default } from "./puppeteer-DGmvuGvT.mjs"; import { n as fetchDesc, r as getItem, t as baseUrl } from "./utils-BvC7TxiJ.mjs"; import { load } from "cheerio"; //#region lib/routes/science/current.ts const route = { path: "/current/:journal?", categories: ["journal"], example: "/science/current/science", parameters: { journal: "Short name for a journal" }, features: { requireConfig: false, requirePuppeteer: true, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: true }, radar: [{ source: ["science.org/journal/:journal", "science.org/toc/:journal/current"], target: "/current/:journal" }], name: "Current Issue", maintainers: ["y9c", "TonyRL"], handler, description: `| Short name | Full name of the journal | Route | | :---------: | :----------------------------: | ------------------------------------------------------------------------------ | | science | Science | [/science/current/science](https://rsshub.app/science/current/science) | | sciadv | Science Advances | [/science/current/sciadv](https://rsshub.app/science/current/sciadv) | | sciimmunol | Science Immunology | [/science/current/sciimmunol](https://rsshub.app/science/current/sciimmunol) | | scirobotics | Science Robotics | [/science/current/scirobotics](https://rsshub.app/science/current/scirobotics) | | signaling | Science Signaling | [/science/current/signaling](https://rsshub.app/science/current/signaling) | | stm | Science Translational Medicine | [/science/current/stm](https://rsshub.app/science/current/stm) | - Using route (\`/science/current/\` + "short name for a journal") to get current issue of a journal from AAAS. - Leaving it empty (\`/science/current\`) to get update from Science.` }; async function handler(ctx) { const { journal = "science" } = ctx.req.param(); const pageURL = `${baseUrl}/toc/${journal}/current`; const { data: pageResponse } = await got_default(pageURL, { headers: { cookie: "cookiePolicy=iaccept;" } }); const $ = load(pageResponse); const pageTitleName = $("head > title").text(); const list = $(".toc__section .card").toArray().map((item) => getItem(item, $)); const browser = await puppeteer_default(); const items = await fetchDesc(list, browser, cache_default.tryGet); await browser.close(); return { title: `${pageTitleName} | Current Issue`, description: `Current Issue of ${pageTitleName}`, image: `${baseUrl}/apple-touch-icon.png`, link: pageURL, language: "en-US", item: items }; } //#endregion export { route };