rsshub
Version:
Make RSS Great Again!
42 lines (41 loc) • 1.47 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/ofweek/news.ts
const route = {
path: "/news",
categories: ["new-media"],
example: "/ofweek/news",
name: "新闻",
maintainers: ["luyuhuang"],
handler
};
async function handler() {
const currentUrl = "https://www.ofweek.com/CATList-8100-CHANGYIEXINWE.html";
const response = await rofetch(currentUrl, { responseType: "arrayBuffer" });
const $ = load(iconv.decode(Buffer.from(response), "gbk"));
const list = $("div.list-left div.con-details h3 > a").slice(0, 20).toArray().map((item) => {
const $item = $(item);
return {
title: $item.text(),
link: $item.attr("href")
};
});
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" });
const artical = load(iconv.decode(Buffer.from(res), "gbk"))("div.artical");
item.description = artical.find("#articleC").html();
item.author = artical.find("div.source-name").text();
item.pubDate = timezone(parseDate(artical.find("div.time.fl").text()), 8);
return item;
})))
};
}
//#endregion
export { route };