UNPKG

rsshub

Version:
64 lines (62 loc) 2.2 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/0818tuan/index.ts const route = { path: "/:listId?", categories: ["shopping"], example: "/0818tuan", parameters: { listId: "活动分类,见下表,默认为 `1`" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "分类", maintainers: ["TonyRL"], handler, description: `| 最新线报 | 实测活动 | 优惠券 | | -------- | -------- | ------ | | 1 | 2 | 3 |` }; async function handler(ctx) { const baseUrl = "http://www.0818tuan.com"; const listId = ctx.req.param("listId") || "1"; const url = `${baseUrl}/list-${listId}-0.html`; const { data: response } = await got_default(url); const $ = load(response); const list = $(listId === "3" ? ".col-xs-12 .thumbnail > a" : ".col-md-8 .list-group > a").toArray().map((item) => { item = $(item); return { title: item.attr("title"), link: item.attr("href").startsWith("http") ? item.attr("href") : `${baseUrl}${item.attr("href")}` }; }).filter((i) => !i.link.includes("m.0818tuan.com/tb1111.php")); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data: response$1 } = await got_default(item.link); const $$1 = load(response$1); $$1(".pageLink, .alert, p[style=\"margin:15px;\"]").remove(); item.description = $$1(".post-content").html(); item.pubDate = timezone(parseDate($$1(".panel-body > .text-center").text().replace("时间:", ""), "YYYY-MM-DD HH:mm:ss"), 8); return item; }))); return { title: $("head title").text(), link: url, image: "http://www.0818tuan.com/favicon.ico", item: items }; } //#endregion export { route };