rsshub
Version:
Make RSS Great Again!
33 lines (32 loc) • 1.02 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs";
import { t as timezone } from "./timezone-UiMFOuvL.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/sh/sthj.ts
const route = {
path: "/sthj",
categories: ["forecast"],
example: "/gov/sh/sthj",
name: "空气质量",
maintainers: ["nczitzk"],
handler
};
async function handler() {
const link = "https://link.sthj.sh.gov.cn/aqi/index.jsp";
const response = await rofetch(link);
const $ = load(response);
const aqi = $("div.val").text();
const time = `${(/* @__PURE__ */ new Date()).getFullYear()}-${$("span.t-time").eq(0).text().replaceAll(/\s+/g, "").replace("月", "-").replace("日", " ").replace("时", ":00:00")}`;
return {
title: "上海市生态环境局 - 空气质量",
link,
item: [{
title: `${aqi} - ${time}`,
link,
description: $("table.table").html() + $("div.air-yb").html(),
pubDate: timezone(parseDate(time), 8)
}]
};
}
//#endregion
export { route };