rsshub
Version:
Make RSS Great Again!
76 lines (75 loc) • 2.01 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 { 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) {
const err = error;
if (err.response && err.response.status === 404) return {
title: newsTitle,
pubDate: parseDate(String(newsTime)),
link,
description: ""
};
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']");
const items = await Promise.all(list.toArray().map((i) => {
const item = $(i);
return getItem(item, cache_default);
}));
return {
title: "西南交大-教务网通知",
link: pageURL,
item: items,
allowEmpty: true
};
}
//#endregion
export { route };