rsshub
Version:
Make RSS Great Again!
47 lines (45 loc) • 1.64 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./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 "./render-BQo6B4tL.mjs";
import "./got-KxxWdaxq.mjs";
import { n as getOriginUrl, t as getArticleDesc } from "./utils-C-dRFGfN.mjs";
import { load } from "cheerio";
//#region lib/routes/jpxgmn/search.ts
const route = {
path: "/search/:kw",
categories: ["picture"],
example: "/jpxgmn/search/candy",
parameters: { kw: "搜索关键词" },
name: "搜索",
maintainers: ["Urabartin"],
handler,
features: { nsfw: true }
};
async function handler(ctx) {
const { kw } = ctx.req.param();
const searchUrl = await getOriginUrl() + `/plus/search/index.asp?keyword=${kw}`;
const response = await ofetch_default.raw(searchUrl);
const baseUrl = new URL(response.url).origin;
const $ = load(response._data);
const items = $("div.list div.list div.node p").toArray().map((item) => ({
title: $(item).find("b").text(),
link: new URL($(item).find("a").attr("href"), baseUrl).href,
pubDate: parseDate($(item).next().next().next().find("span").first().text())
})).filter((item) => item.title.length !== 0);
return {
title: `极品性感美女搜索 - ${kw}`,
link: response.url,
item: await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
item.description = await getArticleDesc(item.link);
return item;
})))
};
}
//#endregion
export { route };