diff --git a/docs/new-media.md b/docs/new-media.md index 4de8a432a..e09f9fad7 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -563,9 +563,9 @@ Tag -| it | soft | win10 | iphone | ipad | android | digi | next | -| ------- | -------- | ---------- | ----------- | --------- | ------------ | -------- | -------- | -| IT 资讯 | 软件之家 | win10 之家 | iphone 之家 | ipad 之家 | android 之家 | 数码之家 | 智能时代 | +| it | soft | win10 | win11 | iphone | ipad | android | digi | next | +| ------- | -------- | ---------- | ---------- | ----------- | --------- | ------------ | -------- | -------- | +| IT 资讯 | 软件之家 | win10 之家 | win11 之家 | iphone 之家 | ipad 之家 | android 之家 | 数码之家 | 智能时代 | @@ -587,6 +587,10 @@ Tag +### 标签 + + + ## IT 桔子 ### 投融资事件 diff --git a/lib/radar-rules.js b/lib/radar-rules.js index d79bcd0de..4811e47d9 100644 --- a/lib/radar-rules.js +++ b/lib/radar-rules.js @@ -975,94 +975,6 @@ module.exports = { ], }, - 'ithome.com': { - _name: 'IT 之家', - '.': [ - { - title: '24 小时阅读榜', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: ['', '/*'], - target: '/ithome/ranking/24h', - }, - { - title: '7 天最热', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: ['', '/*'], - target: '/ithome/ranking/7days', - }, - { - title: '月榜', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: ['', '/*'], - target: '/ithome/ranking/monthly', - }, - ], - it: [ - { - title: 'IT 资讯', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/it', - }, - ], - soft: [ - { - title: '软件之家', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/soft', - }, - ], - win10: [ - { - title: 'win10 之家', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/win10', - }, - ], - iphone: [ - { - title: 'iphone 之家', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/iphone', - }, - ], - ipad: [ - { - title: 'ipad 之家', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/ipad', - }, - ], - android: [ - { - title: 'android 之家', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/android', - }, - ], - digi: [ - { - title: '数码之家', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/digi', - }, - ], - next: [ - { - title: '智能时代', - docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia', - source: '/', - target: '/ithome/next', - }, - ], - }, - 'govopendata.com': { _name: '新闻联播文字版', cn: [ diff --git a/lib/router.js b/lib/router.js index 07ccad752..5a3ac791c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2353,10 +2353,6 @@ router.get('/nyaa/search/:query?', lazyloadRouteHandler('./routes/nyaa/search')) // 片源网 router.get('/pianyuan/:media?', lazyloadRouteHandler('./routes/pianyuan/app')); -// ITHome -router.get('/ithome/:caty', lazyloadRouteHandler('./routes/ithome/index')); -router.get('/ithome/ranking/:type', lazyloadRouteHandler('./routes/ithome/ranking')); - // 巴哈姆特 router.get('/bahamut/creation/:author/:category?', lazyloadRouteHandler('./routes/bahamut/creation')); router.get('/bahamut/creation_index/:category?/:subcategory?/:type?', lazyloadRouteHandler('./routes/bahamut/creation_index')); diff --git a/lib/routes/ithome/index.js b/lib/v2/ithome/index.js similarity index 97% rename from lib/routes/ithome/index.js rename to lib/v2/ithome/index.js index 0862225f6..340def4f7 100644 --- a/lib/routes/ithome/index.js +++ b/lib/v2/ithome/index.js @@ -13,6 +13,9 @@ const config = { win10: { title: 'win10 之家', }, + win11: { + title: 'win11 之家', + }, iphone: { title: 'iphone 之家', }, diff --git a/lib/v2/ithome/maintainer.js b/lib/v2/ithome/maintainer.js index 49b35abc8..55f9dff34 100644 --- a/lib/v2/ithome/maintainer.js +++ b/lib/v2/ithome/maintainer.js @@ -1,3 +1,6 @@ module.exports = { + '/ranking/:type': ['immmortal', 'luyuhuang'], + '/tag/:name': ['Fatpandac'], '/zt/:id': ['nczitzk'], + '/:caty': ['luyuhuang'], }; diff --git a/lib/v2/ithome/radar.js b/lib/v2/ithome/radar.js index f999dd4cc..8b7572fb9 100644 --- a/lib/v2/ithome/radar.js +++ b/lib/v2/ithome/radar.js @@ -1,13 +1,109 @@ module.exports = { 'ithome.com': { - _name: 'IT之家', + _name: 'IT 之家', '.': [ + { + title: '标签', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-zhuan-ti', + source: ['/tag/:name'], + target: '/ithome/tag/:name', + }, { title: '专题', docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-zhuan-ti', source: ['/zt/:id'], target: '/ithome/zt/:id', }, + { + title: '24 小时阅读榜', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-re-bang', + source: ['', '/*'], + target: '/ithome/ranking/24h', + }, + { + title: '7 天最热', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-re-bang', + source: ['', '/*'], + target: '/ithome/ranking/7days', + }, + { + title: '月榜', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-re-bang', + source: ['', '/*'], + target: '/ithome/ranking/monthly', + }, + ], + it: [ + { + title: 'IT 资讯', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/it', + }, + ], + soft: [ + { + title: '软件之家', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/soft', + }, + ], + win10: [ + { + title: 'win10 之家', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/win10', + }, + ], + win11: [ + { + title: 'win11 之家', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/win11', + }, + ], + iphone: [ + { + title: 'iphone 之家', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/iphone', + }, + ], + ipad: [ + { + title: 'ipad 之家', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/ipad', + }, + ], + android: [ + { + title: 'android 之家', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/android', + }, + ], + digi: [ + { + title: '数码之家', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/digi', + }, + ], + next: [ + { + title: '智能时代', + docs: 'https://docs.rsshub.app/new-media.html#it-zhi-jia-fen-lei-zi-xun', + source: '/', + target: '/ithome/next', + }, ], }, }; diff --git a/lib/routes/ithome/ranking.js b/lib/v2/ithome/ranking.js similarity index 100% rename from lib/routes/ithome/ranking.js rename to lib/v2/ithome/ranking.js diff --git a/lib/v2/ithome/router.js b/lib/v2/ithome/router.js index 18214a15b..87eed6fd1 100644 --- a/lib/v2/ithome/router.js +++ b/lib/v2/ithome/router.js @@ -1,3 +1,6 @@ module.exports = function (router) { + router.get('/ranking/:type', require('./ranking')); + router.get('/tag/:name', require('./tag')); router.get('/zt/:id', require('./zt')); + router.get('/:caty', require('./index')); }; diff --git a/lib/v2/ithome/tag.js b/lib/v2/ithome/tag.js new file mode 100644 index 000000000..d8df0a142 --- /dev/null +++ b/lib/v2/ithome/tag.js @@ -0,0 +1,48 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://www.ithome.com/'; + +module.exports = async (ctx) => { + const name = ctx.params.name; + const url = `${rootUrl}/tag/${name}`; + + const response = await got(url); + const $ = cheerio.load(response.data); + const list = $('ul.bl > li') + .map((_, item) => ({ + title: $(item).find('h2 > a').text(), + link: $(item).find('h2 > a').attr('href'), + pubDate: timezone(parseDate($(item).find('div.c').attr('data-ot')), +8), + })) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got(item.link); + const content = cheerio.load(detailResponse.data); + + const article = content('div.post_content'); + article.find('img[data-original]').each((_, ele) => { + ele = $(ele); + ele.attr('src', ele.attr('data-original')); + ele.removeAttr('class'); + ele.removeAttr('data-original'); + }); + item.description = article.html(); + item.author = content('span.author_baidu > strong').text(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `IT之家 - ${name}标签`, + link: url, + item: items, + }; +};