mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat(route): 中国纺织经济信息网资讯 (#7213)
Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
@@ -2452,6 +2452,30 @@ column 为 third 时可选的 category:
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国纺织经济信息网
|
||||
|
||||
### 资讯
|
||||
|
||||
<Route author="nczitzk" example="/ctei/news/bwzq" path="/ctei/news/:id?" :paramsDesc="['分类 id,可在分类页的 URL 中找到,默认为本网专区']">
|
||||
|
||||
| 要闻 | 国内 | 国际 | 企业 | 品牌 | 外贸 | 政策 | 科技 | 流行 | 服装 | 家纺 |
|
||||
| ------ | -------- | -------- | ------- | ----- | ----- | ------ | ---------- | ------- | ------- | ------- |
|
||||
| newsyw | domestic | internal | company | brand | trade | policy | Technology | fashion | apparel | hometex |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国计算机学会
|
||||
|
||||
### 新闻
|
||||
|
||||
<Route author="nczitzk" example="/ccf/news" path="/ccf/news/:category?" :paramsDesc="['分类,见下表,默认为 CCF 新闻']">
|
||||
|
||||
| CCF 新闻 | CCF 聚焦 | ACM 信息 |
|
||||
| ---------- | -------- | -------- |
|
||||
| Media_list | Focus | ACM_News |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国机械工程学会
|
||||
|
||||
### 学会新闻
|
||||
|
||||
@@ -4158,6 +4158,8 @@ router.get('/tanchinese/:category?', require('./routes/tanchinese'));
|
||||
// Harvard
|
||||
router.get('/harvard/health/blog', require('./routes/universities/harvard/health/blog'));
|
||||
|
||||
// 中国纺织经济信息网
|
||||
router.get('/ctei/news/:id?', require('./routes/ctei/news'));
|
||||
// 时事一点通
|
||||
router.get('/ssydt/article/:id?', require('./routes/ssydt/article'));
|
||||
|
||||
|
||||
51
lib/routes/ctei/news.js
Normal file
51
lib/routes/ctei/news.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id || 'bwzq';
|
||||
|
||||
const rootUrl = 'http://news.ctei.cn';
|
||||
const currentUrl = `${rootUrl}/${id}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.news_text ul li a')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${currentUrl}${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,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.TRS_Editor').html();
|
||||
item.pubDate = parseDate(item.link.match(/\/t(\d{8})_\d+.htm/)[1], 'YYYYMMDD');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user