rsshub
Version:
Make RSS Great Again!
41 lines (40 loc) • 1.36 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 { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
import iconv from "iconv-lite";
//#region lib/routes/creaders/headline.ts
const route = {
path: "/headline",
categories: ["bbs"],
example: "/creaders/headline",
name: "焦点新闻",
maintainers: ["nczitzk"],
handler
};
async function handler() {
const currentUrl = "https://news.creaders.net/headline/";
const response = await rofetch(currentUrl, { responseType: "arrayBuffer" });
const $ = load(iconv.decode(Buffer.from(response), "gbk"));
const list = $("ul.newslist li").slice(0, 10).toArray().map((item) => {
const $item = $(item);
const a = $item.find("a").eq(1);
return {
title: a.text(),
link: a.attr("href"),
pubDate: timezone(parseDate($item.find("time").text()), 8)
};
});
return {
title: "万维读者 - 焦点新闻",
link: currentUrl,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const res = await rofetch(item.link, { responseType: "arrayBuffer" });
item.description = load(iconv.decode(Buffer.from(res), "gbk"))("#newsContent").html();
return item;
})))
};
}
//#endregion
export { route };