UNPKG

rsshub

Version:
42 lines (41 loc) 1.59 kB
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/uisdc/hangye.ts const route = { path: "/hangye/:caty?", categories: ["design"], example: "/uisdc/hangye", parameters: { caty: "分类,见下表,默认为全部新闻" }, description: `| 全部新闻 | 活动赛事 | 品牌资讯 | 新品推荐 | | -------- | --------------- | ---------- | ------------ | | | events-activity | brand-news | new-products |`, features: { antiCrawler: true }, name: "行业新闻", maintainers: ["nczitzk"], handler }; async function handler(ctx) { const { caty = "" } = ctx.req.param(); const currentUrl = `https://www.uisdc.com/category/hangye${caty === "" ? "" : "/" + caty}`; const $ = load(await rofetch(currentUrl)); const list = $(".hangye-list-item .hy-title a").slice(0, 10).toArray().map((item) => ({ link: $(item).attr("href") ?? "" })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load(await rofetch(item.link)); return { title: content(".post-title").text().trim(), link: item.link, description: content(".article").html(), pubDate: timezone(parseDate(content(".meta-time").attr("title")), 8) }; }))); return { title: `${$(".current").text()} - 优设网 - UISDC`, link: currentUrl, item: items }; } //#endregion export { route };