UNPKG

rsshub

Version:
45 lines (44 loc) 1.51 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { load } from "cheerio"; //#region lib/routes/muchong/journal.ts const route = { path: "/journal/:type?", categories: ["bbs"], example: "/muchong/journal", parameters: { type: "类型,见下表" }, name: "期刊点评", maintainers: ["nczitzk"], description: `| SCI 期刊 | 中文期刊 | | -------- | -------- | | | cn |`, handler }; async function handler(ctx) { const { type = "" } = ctx.req.param(); const rootUrl = "http://muchong.com"; const decoder = new TextDecoder("gbk"); const currentUrl = `${rootUrl}/${type === "" ? "bbs/journal" : "journal_cn"}.php`; const response = await rofetch(currentUrl, { responseType: "arrayBuffer" }); const $ = load(decoder.decode(response)); const list = $(".jname a, .journal_list a").slice(0, 15).toArray().map((element) => { const $item = $(element); const link = $item.attr("href"); return { title: $item.text(), link: link.includes("http") ? link : `${rootUrl}/bbs/${link}` }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await rofetch(item.link, { responseType: "arrayBuffer" }); item.description = load(decoder.decode(detailResponse))(".forum_explan dl table").eq(1).html(); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };