rsshub
Version:
Make RSS Great Again!
58 lines (56 loc) • 1.9 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.mjs";
import "./helpers-Bo4JQYdN.mjs";
import "./proxy-CjvoY5ys.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
import { n as puppeteer_default } from "./puppeteer-9J9JS5H4.mjs";
import { n as fetchDesc, r as getItem, t as baseUrl } from "./utils-DmL_HifY.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 };