UNPKG

rsshub

Version:
67 lines (64 loc) 2.19 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./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 { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; import iconv from "iconv-lite"; //#region lib/routes/inewsweek/index.ts const rootUrl = "http://news.inewsweek.cn"; const route = { path: "/:channel", categories: ["traditional-media"], example: "/inewsweek/survey", parameters: { channel: "栏目" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["inewsweek.cn/:channel", "inewsweek.cn/"] }], name: "栏目", maintainers: ["changren-wcr"], handler, description: `提取文章全文。 | 封面 | 时政 | 社会 | 经济 | 国际 | 调查 | 人物 | | ----- | -------- | ------- | ------- | ----- | ------ | ------ | | cover | politics | society | finance | world | survey | people |` }; async function handler(ctx) { const url = `${rootUrl}/${ctx.req.param("channel")}`; const response = await got_default(url, { responseType: "buffer" }); const $ = load(iconv.decode(response.data, "gbk")); const items = await Promise.all($("div.grid-item").toArray().map((item) => { item = $(item); const articleLink = `${rootUrl}${item.find("a").attr("href")}`; return cache_default.tryGet(articleLink, async () => { const response$1 = await got_default(articleLink, { responseType: "buffer" }); const $$1 = load(iconv.decode(response$1.data, "gbk")); const fullText = $$1("div.contenttxt").html(); const time = timezone(parseDate($$1("div.editor").html().split(/(\s\s+)/)[2]), 8); return { title: item.find("p").text(), description: fullText, link: articleLink, pubDate: time }; }); })); return { title: $("title").text(), link: url, item: items }; } //#endregion export { route };