rsshub
Version:
Make RSS Great Again!
59 lines (57 loc) • 1.93 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 "./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/early.ts
const route = {
path: "/early/:journal?",
categories: ["journal"],
example: "/science/early",
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/0/0"],
target: "/early/:journal"
}],
name: "First Release",
maintainers: ["y9c", "TonyRL"],
handler,
description: `*only Science, Science Immunology and Science Translational Medicine have first release*`
};
async function handler(ctx) {
const { journal = "science" } = ctx.req.param();
const pageUrl = `${baseUrl}/toc/${journal}/0/0`;
const { data: res } = await got_default(pageUrl, { headers: { cookie: "cookiePolicy=iaccept;" } });
const $ = load(res);
const list = $(".card-content .card-header").toArray().map((item) => getItem(item, $));
const browser = await puppeteer_default();
const items = await fetchDesc(list, browser, cache_default.tryGet);
await browser.close();
return {
title: $("head title").text(),
description: $(".body02").text().trim(),
image: `${baseUrl}/apple-touch-icon.png`,
link: pageUrl,
language: "en-US",
item: items
};
}
//#endregion
export { route };