rsshub
Version:
Make RSS Great Again!
58 lines (57 loc) • 2.1 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";
import pMap from "p-map";
//#region lib/routes/lwn/alerts.ts
const route = {
path: "/alerts/:distributor",
categories: ["programming"],
example: "/lwn/alerts/CentOS",
features: { antiCrawler: true },
parameters: { distributor: "Distribution identification" },
name: "Security alerts",
maintainers: ["zengxs"],
description: `| Distribution | Identification |
| :--------------- | :----------------- |
| Arch Linux | \`Arch_Linux\` |
| CentOS | \`CentOS\` |
| Debian | \`Debian\` |
| Fedora | \`Fedora\` |
| Gentoo | \`Gentoo\` |
| Mageia | \`Mageia\` |
| openSUSE | \`openSUSE\` |
| Oracle | \`Oracle\` |
| Red Hat | \`Red_Hat\` |
| Scientific Linux | \`Scientific_Linux\` |
| Slackware | \`Slackware\` |
| SUSE | \`SUSE\` |
| Ubuntu | \`Ubuntu\` |`,
handler
};
async function handler(ctx) {
const { distributor } = ctx.req.param();
const listUrl = `https://lwn.net/Alerts/${distributor}/`;
const $ = load(await rofetch(listUrl));
return {
title: $(".PageHeadline").text(),
link: listUrl,
item: await pMap($(".ArticleText").find("table tbody tr:not(:first-of-type)").toArray().map((item) => {
const $item = $(item);
return {
link: new URL($item.find("td > a").attr("href"), "https://lwn.net").href,
pubDate: parseRelativeDate($item.find("td:nth-of-type(3)").text())
};
}), (item) => cache_default.tryGet(`LWN.net:${item.link}`, async () => {
const content = load(await rofetch(item.link));
return {
title: content(".PageHeadline").text(),
description: content(".ArticleText").html(),
link: item.link,
pubDate: item.pubDate
};
}), { concurrency: 2 })
};
}
//#endregion
export { route };