rsshub
Version:
Make RSS Great Again!
47 lines (46 loc) • 1.63 kB
JavaScript
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs";
import { t as cache_default } from "./cache-BkqOokyU.mjs";
import { t as got_default } from "./got-BTowW50G.mjs";
import { t as timezone } from "./timezone-BBvDwS_3.mjs";
import { load } from "cheerio";
//#region lib/routes/sspu/jwc.ts
const route = {
path: "/jwc/:listId",
categories: ["university"],
example: "/sspu/jwc/897",
parameters: { listId: "专栏 ID,见下表" },
radar: [{ source: ["jwc.sspu.edu.cn/jwc/:listId/list.htm"] }],
name: "教务处",
maintainers: ["TonyRL"],
handler,
description: `| 学生专栏 | 教师专栏 |
| -------- | -------- |
| 897 | 898 |`
};
async function handler(ctx) {
const listId = ctx.req.param("listId");
const baseUrl = "https://jwc.sspu.edu.cn";
const { data: response, url: link } = await got_default(`${baseUrl}/${listId}/list.htm`);
const $ = load(response);
const list = $(".news_list .news").slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 15).toArray().map((item) => {
const title = $(item).find(".news_title a");
return {
title: title.attr("title"),
link: `${baseUrl}${title.attr("href")}`
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const { data: response } = await got_default(item.link);
const $ = load(response);
item.description = $(".wp_articlecontent").html();
item.pubDate = timezone(parseDate($(".arti_update").text(), "YYYY-MM-DD HH:mm:ss"), 8);
return item;
})));
return {
title: $("head title").text(),
link,
item: items
};
}
//#endregion
export { route };