rsshub
Version:
Make RSS Great Again!
39 lines (38 loc) • 1.27 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/dbaplus/activity.ts
const route = {
path: "/activity/:type?",
categories: ["programming"],
example: "/dbaplus/activity",
parameters: { type: "分类,见下表,默认为线上分享" },
name: "活动",
maintainers: ["nczitzk"],
description: `| 线上分享 | 线下峰会 |
| -------- | -------- |
| online | offline |`,
handler
};
async function handler(ctx) {
const { type = "online" } = ctx.req.param();
const currentUrl = `https://dbaplus.cn/activity-${type === "online" ? "12" : "48"}-1.html`;
const $ = load(await rofetch(currentUrl));
const items = $(".media").toArray().map((element) => {
const item = $(element);
return {
title: item.find(".media-heading").text(),
link: item.find(".pull-left").attr("href"),
description: `<img src="${item.find(".media-object").attr("src")}">`,
pubDate: timezone(parseDate(item.find(".time").text().replace("时间:", "")), 8)
};
});
return {
title: $("title").text().split(":", 1)[0],
link: currentUrl,
item: items
};
}
//#endregion
export { route };