rsshub
Version:
Make RSS Great Again!
80 lines (78 loc) • 2.15 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 { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/swjtu/jwc.ts
const rootURL = "http://jwc.swjtu.edu.cn";
const pageURL = `${rootURL}/vatuu/WebAction?setAction=newsList`;
const getItem = (item, cache) => {
const newsInfo = item.find("h3").find("a");
const newsTime = item.find("p").find("span").text().slice(0, 19);
const newsTitle = newsInfo.text();
const link = `${rootURL}${newsInfo.attr("href").slice(2)}`;
return cache.tryGet(link, async () => {
try {
let newsText = load((await got_default({
method: "get",
url: link
})).data)(".content-main").html();
if (!newsText) newsText = "转发通知";
return {
title: newsTitle,
pubDate: parseDate(String(newsTime)),
link,
description: newsText
};
} catch (error) {
if (error.response && error.response.status === 404) return {
title: newsTitle,
pubDate: parseDate(String(newsTime)),
link,
description: ""
};
else throw error;
}
});
};
const route = {
path: "/jwc",
categories: ["university"],
example: "/swjtu/jwc",
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["jwc.swjtu.edu.cn/vatuu/WebAction", "jwc.swjtu.edu.cn/"] }],
name: "教务网",
maintainers: ["mobyw"],
handler,
url: "jwc.swjtu.edu.cn/vatuu/WebAction"
};
async function handler() {
const $ = load((await got_default({
method: "get",
url: pageURL
})).data);
const list = $("[class='littleResultDiv']");
return {
title: "西南交大-教务网通知",
link: pageURL,
item: await Promise.all(list.toArray().map((i) => {
return getItem($(i), cache_default);
})),
allowEmpty: true
};
}
//#endregion
export { route };