feat(route): add 腾讯研究院 (#9159)

* feat(route): add 腾讯研究院

* Update lib/v2/tisi/index.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/tisi/radar.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* fix(route): change radar docs link

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
Fatpandac
2022-02-20 22:57:32 +08:00
committed by GitHub
parent 0fabd6af38
commit 2f0e3ada69
5 changed files with 67 additions and 0 deletions

View File

@@ -2983,6 +2983,12 @@ column 为 third 时可选的 category:
<Route author="LogicJake" example="/tencent/news/author/5933889" path="/tencent/news/author/:mid" :paramsDesc="['企鹅号 ID']"/>
## 腾讯研究院
### 最近更新
<Route author="Fatpandac" example="/tisi/latest" path="/tisi/latest"/>
## 通識・現代中國
### 議題熱話

38
lib/v2/tisi/index.js Normal file
View File

@@ -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,
};
};

View File

@@ -0,0 +1,3 @@
module.exports = {
'/latest': ['Fatpandac'],
};

17
lib/v2/tisi/radar.js Normal file
View File

@@ -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';
}
},
},
],
},
};

3
lib/v2/tisi/router.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/latest', require('./index'));
};