feat(route): add 中国收入分配研究院 (#7453)
* feat(route): add 中国收入分配研究院 * fix typo * refactor: migrate to v2 Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
parent
2f0e3ada69
commit
c1cbcc139c
|
|
@ -3645,6 +3645,18 @@ column 为 third 时可选的 category:
|
|||
|
||||
<Route author="nczitzk" example="/clb/commentary" path="/clb/commentary/:lang?" :paramsDesc="['语言,默认为简体中文,可选 `en` 即英文']"/>
|
||||
|
||||
## 中国收入分配研究院
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/ciidbnu" path="/ciidbnu/:id?" :paramsDesc="['分类 id,可在分类页地址栏 URL 中找到']">
|
||||
|
||||
| 社会动态 | 院内新闻 | 学术观点 | 文献书籍 | 工作论文 | 专题讨论 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| 1 | 5 | 3 | 4 | 6 | 8 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国橡胶网
|
||||
|
||||
### 新闻资讯
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '1';
|
||||
|
||||
const rootUrl = 'http://www.ciidbnu.org';
|
||||
const currentUrl = `${rootUrl}/new1.asp?pagetype=${id}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('#newsrightlist a')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href').replace('..', '')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
|
||||
item.description = content('#text').html();
|
||||
item.pubDate = timezone(parseDate(content('.t8').eq(0).text(), 'YYYY/M/D H:mm:ss'), +8);
|
||||
|
||||
content('.t14').remove();
|
||||
|
||||
item.author = content('#author').text();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('h3').text()} - 中国收入分配研究院`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'ciidbnu.org': {
|
||||
_name: '中国收入分配研究院',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#',
|
||||
source: ['/new1.asp', '/'],
|
||||
target: (_params, url) => `/ciidbnu/${new URL(url).searchParams.get('pagetype')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/:id?', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue