rsshub
Version:
Make RSS Great Again!
44 lines (43 loc) • 1.56 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";
//#region lib/routes/tongshang/index.ts
const route = {
path: "/",
categories: ["other"],
example: "/tongshang",
name: "通商",
maintainers: ["snipersteve"],
handler
};
async function handler() {
const url = "https://www.tongshang.com/article/research/";
const oriUrl = "https://www.tongshang.com";
const match = (await rofetch(`${oriUrl}/TemResolve/?TemPresolveId=32&classid=30&ObjI=0&publicvar=1&charset=UTF-8`, { responseType: "text" })).match(/document\.write\((".*")\);/s);
if (!match) throw new Error("Unable to extract the article list from the template response");
const $ = load(JSON.parse(match[1].replaceAll(/[\r\n\t]/g, " ")));
const list = $("li").toArray();
return {
title: "通商研究 - 通商律师事务所",
link: url,
item: await Promise.all(list.map((item) => {
const $item = $(item);
const subUrl = $item.find("a").attr("href");
const itemUrl = oriUrl + subUrl;
const pubDate = timezone(parseDate($item.find(".font_ts").text()), 8);
return cache_default.tryGet(itemUrl, async () => {
const $d = load(await rofetch(itemUrl));
return {
title: $d(".lm_newsCont_part1 .txt").text(),
link: itemUrl,
pubDate,
description: $d(".lm_newsCont_part2 .left").html()
};
});
}))
};
}
//#endregion
export { route };