mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
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:
@@ -131,6 +131,25 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
|
|||||||
|
|
||||||
</RouteEn>
|
</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
|
## Common App
|
||||||
|
|
||||||
### Blog
|
### Blog
|
||||||
|
|||||||
@@ -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="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>
|
||||||
|
|
||||||
## 重构
|
## 重构
|
||||||
|
|
||||||
### 推荐
|
### 推荐
|
||||||
|
|||||||
4
lib/v2/china/maintainer.js
Normal file
4
lib/v2/china/maintainer.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/news/military': ['jiaaoMario'],
|
||||||
|
'/news/:category?': ['jiaaoMario'],
|
||||||
|
};
|
||||||
40
lib/v2/china/news/highlights/news.js
Normal file
40
lib/v2/china/news/highlights/news.js
Normal 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(),
|
||||||
|
};
|
||||||
|
};
|
||||||
31
lib/v2/china/news/military/news.js
Normal file
31
lib/v2/china/news/military/news.js
Normal 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
21
lib/v2/china/radar.js
Normal 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
4
lib/v2/china/router.js
Normal 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'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user