diff --git a/docs/new-media.md b/docs/new-media.md index f57d19a6c..19403c17c 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2983,6 +2983,12 @@ column 为 third 时可选的 category: +## 腾讯研究院 + +### 最近更新 + + + ## 通識・現代中國 ### 議題熱話 diff --git a/lib/v2/tisi/index.js b/lib/v2/tisi/index.js new file mode 100644 index 000000000..f00833fa9 --- /dev/null +++ b/lib/v2/tisi/index.js @@ -0,0 +1,38 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://www.tisi.org'; + +module.exports = async (ctx) => { + const url = `${rootUrl}/?page_id=11151`; + + const response = await got(url); + const $ = cheerio.load(response.data); + const list = $('div.new-artice-list-box') + .map((_, item) => ({ + title: $(item).find('p.new-article-title > a').text(), + link: new URL($(item).find('p.new-article-title > a').attr('href'), rootUrl).href, + pubDate: parseDate($(item).find('p.new-article-date > span.left-span').text()), + category: $(item).find('p.new-article-date > span:nth-child(1)').text(), + })) + .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); + item.description = content('div.article-content').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '腾讯研究院 - 最近更新', + link: url, + item: items, + }; +}; diff --git a/lib/v2/tisi/maintainer.js b/lib/v2/tisi/maintainer.js new file mode 100644 index 000000000..bea03de5e --- /dev/null +++ b/lib/v2/tisi/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/latest': ['Fatpandac'], +}; diff --git a/lib/v2/tisi/radar.js b/lib/v2/tisi/radar.js new file mode 100644 index 000000000..b5294973c --- /dev/null +++ b/lib/v2/tisi/radar.js @@ -0,0 +1,17 @@ +module.exports = { + 'tisi.org': { + _name: '腾讯研究院', + '.': [ + { + title: '最近更新', + docs: 'https://docs.rsshub.app/new-media.html#teng-xun-yan-jiu-yuan', + source: ['/'], + target: (_params, url) => { + if (new URL(url).searchParams.get('page_id') === '11151') { + return '/tisi/latest'; + } + }, + }, + ], + }, +}; diff --git a/lib/v2/tisi/router.js b/lib/v2/tisi/router.js new file mode 100644 index 000000000..e20373cf8 --- /dev/null +++ b/lib/v2/tisi/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/latest', require('./index')); +};