rsshub
Version:
Make RSS Great Again!
39 lines (37 loc) • 1.44 kB
JavaScript
import { t as md5 } from "./md5-CpIHIxCO.mjs";
import { t as got_default } from "./got-BTowW50G.mjs";
import { load } from "cheerio";
//#region lib/routes/qiyoujiage/price.ts
const route = {
path: "/:path{.+}",
categories: ["other"],
example: "/qiyoujiage/shanghai",
parameters: { path: "路径" },
description: `::: tip
路径处填写对应页面 URL 中 \`http://www.qiyoujiage.com/\` 和 \`.shtml\` 之间的字段。下面是一个例子。
若订阅 [福建漳州龙海今日油价](http://www.qiyoujiage.com/fujian/zhangzhou/longhai.shtml) 则将对应页面 URL <http://www.qiyoujiage.com/fujian/zhangzhou/longhai.shtml> 中 \`http://www.qiyoujiage.com/\` 和 \`.shtml\` 之间的字段 \`fujian/zhangzhou/longhai\` 作为路径填入。此时路由为 [\`/qiyoujiage/fujian/zhangzhou/longhai\`](https://rsshub.app/qiyoujiage/fujian/zhangzhou/longhai)
:::`,
name: "今日油价查询",
maintainers: ["TonyRL"],
handler
};
async function handler(ctx) {
const link = `http://www.qiyoujiage.com/${ctx.req.param("path")}.shtml`;
const { data: response } = await got_default(link);
const $ = load(response);
const priceText = $("#youjia").text();
const item = [{
title: priceText,
description: $("#youjia").html(),
link,
guid: `${link}#${md5(priceText)}`
}];
return {
title: $("title").text(),
description: $("meta[name=\"Description\"]").attr("content"),
link,
item
};
}
//#endregion
export { route };