feat: 新增china.com RSS (#10532)

* feat: add news router

* feat: add news path

* feat: change website category

* feat: complate zhonghuawang

* style: format code

* docs: add english router doc

* feat: 调整文件名称

* feat: 添加时间处理

* feat: cr commit

Co-authored-by: majiaao <jiaaoMario@gmail.com>
This commit is contained in:
mario.ma
2022-08-19 01:53:29 +08:00
committed by GitHub
parent 2bcddf44c3
commit d2eb1ac19c
7 changed files with 162 additions and 24 deletions

View File

@@ -131,6 +131,25 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
</RouteEn>
## China.com
### Military - Military News
<RouteEn author="jiaaoMario" example="/china/news/military" path="/china/news/military">
</RouteEn>
### News and current affairs
<RouteEn author="jiaaoMario" example="/china/news" path="/china/news/:category?" :paramsDesc="['Category of news. See the form below for details, default is china news.']">
Category of news
| China News | International News | Social News | Breaking News |
| -------- | ------------- | ------ | ------- |
| domestic | international | social | news100 |
</RouteEn>
## Common App
### Blog

View File

@@ -2615,51 +2615,51 @@ column 为 third 时可选的 category:
- 人工智能
| 学术 | 开发者 |
| -------- | -------- |
| academic | yanxishe |
| 学术 | 开发者 |
| -------- | -------- |
| academic | yanxishe |
- 数智化
| 零售数智化 | 金融数智化 | 工业数智化 | 医疗数智化 | 城市数智化 |
| --------- | ---------- | ---------- | --------- | ----------- |
| redigital | findigital | mandigital | medigital | citydigital |
| 零售数智化 | 金融数智化 | 工业数智化 | 医疗数智化 | 城市数智化 |
| --------- | ---------- | ---------- | --------- | ----------- |
| redigital | findigital | mandigital | medigital | citydigital |
- 金融科技
| 科技巨头 | 银行 AI | 金融云 | 风控与安全 |
| ------- | ----- | ------------ | ------------ |
| BigTech | bank | FinanceCloud | DataSecurity |
| 科技巨头 | 银行 AI | 金融云 | 风控与安全 |
| ------- | ----- | ------------ | ------------ |
| BigTech | bank | FinanceCloud | DataSecurity |
- 医疗科技
| 医疗 AI | 投融资 | 医疗器械 | 互联网医疗 | 生物医药 | 健康险 |
| -------- | ----- | ----- | ---------------- | ------------ | ------------ |
| healthai | touzi | qixie | hulianwangyiliao | shengwuyiyao | jiankangxian |
| 医疗 AI | 投融资 | 医疗器械 | 互联网医疗 | 生物医药 | 健康险 |
| -------- | ----- | ----- | ---------------- | ------------ | ------------ |
| healthai | touzi | qixie | hulianwangyiliao | shengwuyiyao | jiankangxian |
- 芯片
| 材料设备 | 芯片设计 | 晶圆代工 | 封装测试 |
| --------- | ---------- | ------------- | --------- |
| materials | chipdesign | manufacturing | packaging |
| 材料设备 | 芯片设计 | 晶圆代工 | 封装测试 |
| --------- | ---------- | ------------- | --------- |
| materials | chipdesign | manufacturing | packaging |
- 智慧城市
| 智慧安防 | 智慧教育 | 智慧交通 | 智慧社区 | 智慧零售 | 智慧政务 | 智慧地产 |
| ------------- | -------------- | ------------------- | -------------- | -------------- | --------------- | -------- |
| smartsecurity | smarteducation | smarttransportation | smartcommunity | smartretailing | smartgovernment | proptech |
| 智慧安防 | 智慧教育 | 智慧交通 | 智慧社区 | 智慧零售 | 智慧政务 | 智慧地产 |
| ------------- | -------------- | ------------------- | -------------- | -------------- | --------------- | -------- |
| smartsecurity | smarteducation | smarttransportation | smartcommunity | smartretailing | smartgovernment | proptech |
- 工业互联网
| 工业软件 | 工业安全 | 5G 工业互联网 | 工业转型实践 |
| ---------- | -------- | -------- | --------- |
| gysoftware | gysafety | 5ggy | gypratice |
| 工业软件 | 工业安全 | 5G 工业互联网 | 工业转型实践 |
| ---------- | -------- | -------- | --------- |
| gysoftware | gysafety | 5ggy | gypratice |
- AIoT
| 物联网 | 智能硬件 | 机器人 | 智能家居 |
| --- | ---- | ----- | --------- |
| 5G | arvr | robot | smarthome |
| 物联网 | 智能硬件 | 机器人 | 智能家居 |
| --- | ---- | ----- | --------- |
| 5G | arvr | robot | smarthome |
</Route>
@@ -4226,6 +4226,25 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/
<Route author="nczitzk" example="/cria/news/1" path="/cria/news/:id?" :paramsDesc="['列表 id可在列表页的 URL 中找到,默认为首页']"/>
## 中华网
### 军事 - 军事新闻
<Route author="jiaaoMario" example="/china/news/military" path="/china/news/military">
</Route>
### 时事新闻
<Route author="jiaaoMario" example="/china/news" path="/china/news/:category?" :paramsDesc="['新闻类型,见下表,默认为国内新闻']">
新闻类型
| 国内新闻 | 国际新闻 | 社会新闻 | 新闻热榜 |
| -------- | ------------- | ------ | ------- |
| domestic | international | social | news100 |
</Route>
## 重构
### 推荐

View File

@@ -0,0 +1,4 @@
module.exports = {
'/news/military': ['jiaaoMario'],
'/news/:category?': ['jiaaoMario'],
};

View File

@@ -0,0 +1,40 @@
const cheerio = require('cheerio');
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const CATEGORY_MAP = {
domestic: 'domestic',
international: 'international',
social: 'social',
news100: 'news100',
};
module.exports = async (ctx) => {
const baseUrl = 'https://news.china.com';
const category = CATEGORY_MAP[ctx.params.category] ?? CATEGORY_MAP.domestic;
const websiteUrl = `${baseUrl}/${category}`;
const response = await got(websiteUrl);
const data = response.data;
const $ = cheerio.load(data);
const categoryTitle = $('.wp_title').text();
const news = $('.item_list li');
ctx.state.data = {
title: `中华网-${categoryTitle}新闻`,
link: websiteUrl,
item:
news &&
news
.map((_, item) => {
item = $(item);
return {
title: item.find('.item_title a').text(),
author: item.find('.item_source').text(),
category: `${categoryTitle}新闻`,
pubDate: parseDate(item.find('.item_time').text()),
description: item.find('.item_title a').text(),
link: item.find('li a').attr('href'),
};
})
.get(),
};
};

View File

@@ -0,0 +1,31 @@
const cheerio = require('cheerio');
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const websiteUrl = 'https://military.china.com/news/';
const response = await got(websiteUrl);
const data = response.data;
const $ = cheerio.load(data);
const commonList = $('.listItem');
ctx.state.data = {
title: '中华网-军事新闻',
link: 'https://military.china.com/news/',
item:
commonList &&
commonList
.map((_, item) => {
item = $(item);
return {
title: item.find('.tit a').text(),
author: '中华网军事',
category: '中华网军事',
pubDate: parseDate(item.find('.time').text()),
description: item.find('.tag').text(),
link: item.find('.tit a').attr('href'),
};
})
.get(),
};
};

21
lib/v2/china/radar.js Normal file
View File

@@ -0,0 +1,21 @@
module.exports = {
'china.com': {
_name: '中华网',
military: [
{
title: '军事新闻',
docs: 'https://docs.rsshub.app/new-media.html#zhong-hua-wang',
source: '/news',
target: '/china/news/military',
},
],
news: [
{
title: '时事新闻',
docs: 'https://docs.rsshub.app/new-media.html#zhong-hua-wang',
source: '/:category',
target: '/china/news/:category?',
},
],
},
};

4
lib/v2/china/router.js Normal file
View File

@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/news/military', require('./news/military/news.js'));
router.get('/news/:category?', require('./news/highlights/news.js'));
};