diff --git a/docs/new-media.md b/docs/new-media.md index 81f597ea9..696edf65c 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2886,6 +2886,18 @@ column 为 third 时可选的 category: ## 网易新闻 +### 今日关注 + + + +::: tip 提示 + +参数 **需要获取全文** 设置为 `true` `yes` `t` `y` 等值后,RSS 会携带该新闻条目的对应全文。 + +::: + + + ### 排行榜 diff --git a/lib/v2/netease/maintainer.js b/lib/v2/netease/maintainer.js index e078a6b77..20f63d2be 100644 --- a/lib/v2/netease/maintainer.js +++ b/lib/v2/netease/maintainer.js @@ -1,4 +1,5 @@ module.exports = { '/renjian/:category?': ['nczitzk'], + '/today/:need_content?': ['nczitzk'], '/news/rank/:category?/:type?/:time?': ['nczitzk'], }; diff --git a/lib/v2/netease/radar.js b/lib/v2/netease/radar.js index 651b8df65..b55de86c3 100644 --- a/lib/v2/netease/radar.js +++ b/lib/v2/netease/radar.js @@ -12,9 +12,17 @@ module.exports = { news: [ { title: '排行榜', - docs: 'https://docs.rsshub.app/.html#', + docs: 'https://docs.rsshub.app/new-media.html#wang-yi-xin-wen-pai-hang-bang', source: ['/:category', '/'], - target: '//:category?', + target: '/netease/news/rank/:category?/:type?/:time?', + }, + ], + m: [ + { + title: '今日关注', + docs: 'https://docs.rsshub.app/new-media.html#wang-yi-xin-wen-jin-ri-guan-zhu', + source: ['/'], + target: '/netease/today/:need_content?', }, ], }, diff --git a/lib/v2/netease/router.js b/lib/v2/netease/router.js index f2d62c9f7..8ee121e68 100644 --- a/lib/v2/netease/router.js +++ b/lib/v2/netease/router.js @@ -1,4 +1,5 @@ module.exports = function (router) { router.get('/renjian/:category?', require('./renjian')); + router.get('/today/:need_content?', require('./today')); router.get('/news/rank/:category?/:type?/:time?', require('./rank')); }; diff --git a/lib/v2/netease/today.js b/lib/v2/netease/today.js new file mode 100644 index 000000000..b14f008b5 --- /dev/null +++ b/lib/v2/netease/today.js @@ -0,0 +1,55 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const needContent = /t|y/i.test(ctx.params.need_content ?? 'true'); + + const rootUrl = 'https://gw.m.163.com'; + const currentUrl = `${rootUrl}/nc/api/v1/feed/static/normal-list?start=0&tid=T1573700340788&size=${ctx.query.limit ?? (needContent ? 30 : 200)}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + let items = response.data.data.items.map((item) => ({ + title: item.title, + author: item.source, + pubDate: timezone(parseDate(item.ptime), +8), + description: `

${item.digest}

`, + link: item.url || `https://c.m.163.com/news/a/${item.docid}.html`, + })); + + if (needContent) { + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + content('.bot_word').remove(); + + content('figure[data-echo]').each(function () { + content(this).html(``); + }); + + item.description = content('.content, article').html(); + + return item; + }) + ) + ); + } + + ctx.state.data = { + title: '今日关注 - 网易新闻', + link: 'https://wp.m.163.com/163/html/newsapp/todayFocus/index.html', + item: items, + }; +};