rsshub
Version:
Make RSS Great Again!
39 lines (38 loc) • 1.17 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { n as parseRelativeDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { load } from "cheerio";
//#region lib/routes/tianyancha/hot.ts
const route = {
path: "/hot",
categories: ["other"],
example: "/tianyancha/hot",
features: { antiCrawler: true },
name: "热门搜索",
maintainers: ["nczitzk"],
handler
};
async function handler() {
const rootUrl = "https://www.tianyancha.com/";
const $ = load(await rofetch(rootUrl));
const list = $(".key").slice(0, 10).toArray().map((item) => {
const $item = $(item);
return {
title: $item.text(),
link: $item.attr("href")
};
});
return {
title: "热门搜索 - 天眼查",
link: rootUrl,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const content = load(await rofetch(item.link));
item.author = content(".resource").text().replace("来源:", "");
item.description = content(".news-content").html();
item.pubDate = parseRelativeDate(content(".resource").next().text());
return item;
})))
};
}
//#endregion
export { route };