diff --git a/docs/new-media.md b/docs/new-media.md index 05cfe1f6a..7480de847 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -3185,6 +3185,56 @@ column 为 third 时可选的 category: +## 乌有之乡 + +### 栏目 + + + +时政 + +| 时代观察 | 舆论战争 | +| -------- | -------- | +| shidai | yulun | + +经济 + +| 经济视点 | 社会民生 | 三农关注 | 产业研究 | +| -------- | -------- | -------- | -------- | +| jingji | shehui | sannong | chanye | + +国际 + +| 国际纵横 | 国防外交 | +| -------- | -------- | +| guoji | guofang | + +思潮 + +| 理想之旅 | 思潮碰撞 | 文艺新生 | 读书交流 | +| -------- | -------- | -------- | -------- | +| lixiang | sichao | wenyi | shushe | + +历史 + +| 历史视野 | 中华文化 | 中华医药 | 共产党人 | +| -------- | -------- | -------- | -------- | +| lishi | zhonghua | zhongyi | cpers | + +争鸣 + +| 风华正茂 | 工农之声 | 网友杂谈 | 网友时评 | +| -------- | -------- | -------- | -------- | +| qingnian | gongnong | zatan | shiping | + +活动 + +| 乌有公告 | 红色旅游 | 乌有讲堂 | 书画欣赏 | +| -------- | -------- | --------- | -------- | +| gonggao | lvyou | jiangtang | shuhua | + + + ## 无产者评论 ### 分类 diff --git a/lib/v2/wyzxwk/article.js b/lib/v2/wyzxwk/article.js new file mode 100644 index 000000000..82e42862b --- /dev/null +++ b/lib/v2/wyzxwk/article.js @@ -0,0 +1,65 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id ?? 'shidai'; + + const rootUrl = 'http://www.wyzxwk.com'; + const currentUrl = `${rootUrl}/Article/${id}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + $('.g-sd').remove(); + + let items = $('h3 a') + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: item.attr('href'), + }; + }); + + items = await Promise.all( + items.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + if (item.link.indexOf('wyzxwk.com') > 0) { + try { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + content('.zs-modal-body').prev().nextAll().remove(); + + const pubDate = detailResponse.data.match(/(\d{4}-\d{2}-\d{2})<\/span>/); + if (pubDate) { + item.pubDate = parseDate(pubDate[1], 'YYYY-MM-DD'); + } + + item.description = content('article').html(); + } catch (e) { + item.description = ''; + } + } + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('title').text().split(' - ')[0]} - 乌有之乡网刊`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/wyzxwk/maintainer.js b/lib/v2/wyzxwk/maintainer.js new file mode 100644 index 000000000..f68490158 --- /dev/null +++ b/lib/v2/wyzxwk/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/article/:id?': ['nczitzk'], +}; diff --git a/lib/v2/wyzxwk/radar.js b/lib/v2/wyzxwk/radar.js new file mode 100644 index 000000000..60afa7c1e --- /dev/null +++ b/lib/v2/wyzxwk/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'wyzxwk.com': { + _name: '乌有之乡', + '.': [ + { + title: '栏目', + docs: 'https://docs.rsshub.app/new-media.html#wu-you-zhi-xiang-lan-mu', + source: ['/Article/:id', '/'], + target: '/wyzxwk/article/:id?', + }, + ], + }, +}; diff --git a/lib/v2/wyzxwk/router.js b/lib/v2/wyzxwk/router.js new file mode 100644 index 000000000..7fd5c10f8 --- /dev/null +++ b/lib/v2/wyzxwk/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/article/:id?', require('./article')); +};