rsshub
Version:
Make RSS Great Again!
41 lines (40 loc) • 1.24 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { n as parseRelativeDate } from "./parse-date-3kcy2Eau.mjs";
import { t as cache_default } from "./cache-C1Y-9qDV.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 response = await rofetch(rootUrl);
const $ = load(response);
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 detailResponse = await rofetch(item.link);
const content = load(detailResponse);
item.author = content(".resource").text().replace("来源:", "");
item.description = content(".news-content").html();
item.pubDate = parseRelativeDate(content(".resource").next().text());
return item;
})))
};
}
//#endregion
export { route };