diff --git a/docs/new-media.md b/docs/new-media.md index 446a6ab3a..a31a91025 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1995,7 +1995,7 @@ others = 热点新闻 + 滚动新闻 ### 科学人 - + ### 果壳网专栏 diff --git a/lib/router.js b/lib/router.js index b32168d33..810cbee70 100644 --- a/lib/router.js +++ b/lib/router.js @@ -813,8 +813,8 @@ router.get('/xmu/aero/:type', lazyloadRouteHandler('./routes/universities/xmu/ae router.get('/ifanr/:channel?', lazyloadRouteHandler('./routes/ifanr/index')); // 果壳网 -router.get('/guokr/scientific', lazyloadRouteHandler('./routes/guokr/scientific')); -router.get('/guokr/:channel', lazyloadRouteHandler('./routes/guokr/calendar')); +// router.get('/guokr/scientific', lazyloadRouteHandler('./routes/guokr/scientific')); +// router.get('/guokr/:channel', lazyloadRouteHandler('./routes/guokr/calendar')); // 联合早报 已经迁移至v2模板 // router.get('/zaobao/realtime/:section?', require('./routes/zaobao/realtime')); diff --git a/lib/routes/guokr/calendar.js b/lib/v2/guokr/channel.js similarity index 86% rename from lib/routes/guokr/calendar.js rename to lib/v2/guokr/channel.js index 2f0dfbb6d..da764e9c9 100644 --- a/lib/routes/guokr/calendar.js +++ b/lib/v2/guokr/channel.js @@ -3,7 +3,7 @@ const got = require('@/utils/got'); async function loadFullPage(ctx, id) { const link = `https://apis.guokr.com/minisite/article/${id}.json`; const content = await ctx.cache.tryGet(link, async () => { - const res = await got.get(link); + const res = await got(link); return res.data.result.content; }); return content; @@ -19,7 +19,7 @@ const channelMap = { module.exports = async (ctx) => { const channel = channelMap[ctx.params.channel] ? channelMap[ctx.params.channel] : ctx.params.channel; - const response = await got.get(`https://www.guokr.com/apis/minisite/article.json?retrieve_type=by_wx&channel_key=${channel}&offset=0&limit=10`); + const response = await got(`https://www.guokr.com/apis/minisite/article.json?retrieve_type=by_wx&channel_key=${channel}&offset=0&limit=10`); const items = response.data.result; if (items.length === 0) { diff --git a/lib/v2/guokr/maintainer.js b/lib/v2/guokr/maintainer.js new file mode 100644 index 000000000..c0ada2b79 --- /dev/null +++ b/lib/v2/guokr/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/scientific': ['alphardex', 'nczitzk'], + '/:channel': ['DHPO', 'hoilc'], +}; diff --git a/lib/v2/guokr/radar.js b/lib/v2/guokr/radar.js new file mode 100644 index 000000000..17581685b --- /dev/null +++ b/lib/v2/guokr/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'guokr.com': { + _name: '果壳网', + '.': [ + { + title: '科学人', + docs: 'https://docs.rsshub.app/new-media.html#guo-ke-wang-ke-xue-ren', + source: ['/scientific', '/'], + target: '/guokr/scientific', + }, + { + title: '专栏', + docs: 'https://docs.rsshub.app/new-media.html#guo-ke-wang-zhuan-lan', + source: ['/'], + target: '/guokr/:channel', + }, + ], + }, +}; diff --git a/lib/v2/guokr/router.js b/lib/v2/guokr/router.js new file mode 100644 index 000000000..5ee121586 --- /dev/null +++ b/lib/v2/guokr/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/scientific', require('./scientific')); + router.get('/:channel', require('./channel')); +}; diff --git a/lib/routes/guokr/scientific.js b/lib/v2/guokr/scientific.js similarity index 78% rename from lib/routes/guokr/scientific.js rename to lib/v2/guokr/scientific.js index 20df38619..92ee525e0 100644 --- a/lib/routes/guokr/scientific.js +++ b/lib/v2/guokr/scientific.js @@ -2,7 +2,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const response = await got.get('https://www.guokr.com/apis/minisite/article.json?retrieve_type=by_subject&limit=20&offset=0'); + const response = await got('https://www.guokr.com/apis/minisite/article.json?retrieve_type=by_subject&limit=20&offset=0'); const result = response.data.result; @@ -13,9 +13,9 @@ module.exports = async (ctx) => { item: await Promise.all( result.map((item) => ctx.cache.tryGet(item.url, async () => { - const res = await got.get(item.url); + const res = await got(item.url); const $ = cheerio.load(res.data); - item.description = $('.eflYNZ #js_content').css('visibility', 'visible').html() || $('.bPfFQI').html(); + item.description = $('.eflYNZ #js_content').css('visibility', 'visible').html() ?? $('.bxHoEL').html(); return { title: item.title, description: item.description,