rsshub
Version:
Make RSS Great Again!
40 lines (39 loc) • 1.12 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { load } from "cheerio";
//#region lib/routes/fate-go/news.ts
const route = {
path: "/news",
categories: ["game"],
example: "/fate-go/news",
name: "News",
maintainers: ["nczitzk"],
handler
};
async function handler() {
const newsUrl = "https://news.fate-go.jp/";
const $ = load(await rofetch(newsUrl));
const list = $("ul.list_news li").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find("p.title").text(),
link: new URL($item.find("a").attr("href"), newsUrl).href,
pubDate: parseDate($item.find("p.date").text())
};
});
return {
title: "Fate Grand Order News",
link: newsUrl,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const content = load(await rofetch(item.link));
content("div.article .title-box").remove();
return {
...item,
description: content("div.article").html()
};
})))
};
}
//#endregion
export { route };