UNPKG

rsshub

Version:
80 lines (76 loc) 3.48 kB
import "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/mox/index.ts const route = { path: "/:category?", categories: ["anime"], example: "/mox", parameters: { category: "分类,可在对应分类页 URL 中找到" }, features: { requireConfig: [{ name: "MOX_COOKIE", optional: true, description: `注册用户登录后的 Cookie, 可以从浏览器开发者工具Network面板中的mox页面请求获取,Cookie内容形如VOLSKEY=xxxxxx; VLIBSID=xxxxxx; VOLSESS=xxxxxx` }], antiCrawler: true }, radar: [{ source: ["mox.moe/l/:category", "mox.moe/"] }], name: "首頁", maintainers: ["nczitzk"], handler, description: `::: tip 在首页将分类参数选择确定后跳转到的分类页面 URL 中,\`/l/\` 后的字段即为分类参数。 如 [科幻 + 日語 + 日本 + 長篇 + 完結 + 最近更新](https://mox.moe/l/CAT%2A科幻,日本,完結,lastupdate,jpn,l,BL) 的 URL 为 [https://mox.moe/l/CAT%2A 科幻,日本,完結,lastupdate,jpn,l,BL](https://mox.moe/l/CAT%2A科幻,日本,完結,lastupdate,jpn,l,BL),此时 \`/l/\` 后的字段为 \`CAT%2A科幻,日本,完結,lastupdate,jpn,l,BL\`。最终获得路由为 [\`/mox/CAT%2A科幻,日本,完結,lastupdate,jpn,l,BL\`](https://rsshub.app/mox/CAT%2A科幻,日本,完結,lastupdate,jpn,l,BL) ::: ::: warning 由于 mox.moe 对非登录用户屏蔽了部分漫画详情内容的获取,且极易触发反爬机制,导致访问ip被重定向至google.com,因此在未配置\`MOX_COOKIE\`参数的情况下路由只会返回漫画标题和封面,不会对详情内容进行抓取。 :::` }; async function handler(ctx) { const category = ctx.req.param("category") ?? ""; const currentUrl = `https://mox.moe${category ? `/l/${category}` : ""}`; const cookie = config.mox.cookie; const $ = load((await got_default({ method: "get", url: currentUrl, headers: { cookie } })).data); let items = $(".listbg td").toArray().map((item) => { const lastItem = $(item).find("a").last(); const guid = lastItem.attr("href")?.split("/").pop(); const cover = $(item).find("a div div").attr("style")?.match(/background:url\((.*?)\)/)?.[1]; return { title: lastItem.text(), description: cover ? `<img src="${cover}">` : void 0, link: lastItem.attr("href"), guid }; }).filter((i) => i.guid); if (cookie) items = await Promise.all(items.map((item) => cache_default.tryGet(item.guid, async () => { const detailResponse = await got_default({ method: "get", url: item.link, headers: { cookie } }); const content = load(detailResponse.data); item.author = content(".author .text_bglight font a").toArray().map((i) => $(i).text()).filter(Boolean).join("、"); const infoBlock = content(".author .text_bglight").toArray(); const desc = detailResponse.data?.match(/document\.getElementById\("div_desc_content"\)\.innerHTML = "(.*?)";/s)?.[1] ?? ""; item.description = `<img src="${content(".img_book").attr("src")}"><br>${infoBlock.map((i) => $(i).html()).join("<br>")}<br>${desc}`; return item; }))); return { title: "Mox.moe", link: currentUrl, item: items }; } //#endregion export { route };