rsshub
Version:
Make RSS Great Again!
43 lines (42 loc) • 1.37 kB
JavaScript
import { t as rofetch } from "./ofetch-eUBdfMpp.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";
//#region lib/routes/haiwen-law/index.ts
const route = {
path: "/",
categories: ["other"],
example: "/haiwen-law",
radar: [{ source: ["www.haiwen-law.com/35"] }],
name: "研究文章",
maintainers: ["snipersteve"],
handler,
url: "www.haiwen-law.com/35/"
};
async function handler() {
const baseUrl = "http://www.haiwen-law.com";
const link = `${baseUrl}/35/`;
const $ = load(await rofetch(link));
const list = $(".xwzx_section ul li a").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find(".tit").text(),
link: new URL($item.attr("href"), baseUrl).href,
pubDate: timezone(parseDate($item.find(".date").text(), "YYYY-MM-DD"), 8)
};
});
const out = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const $ = load(await rofetch(item.link));
item.description = $(".yjwzwz_section .text1").html()?.trim();
item.author = $(".wordsbox .zz span").toArray().map((e) => $(e).text().trim()).join(", ");
return item;
})));
return {
title: $("head title").text(),
link,
item: out
};
}
//#endregion
export { route };