mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: Add China Dialogue (#3748)
This commit is contained in:
@@ -26,6 +26,28 @@ Support major channels, refer to [BBC RSS feeds](https://www.bbc.co.uk/news/1062
|
|||||||
|
|
||||||
</RouteEn>
|
</RouteEn>
|
||||||
|
|
||||||
|
## China Dialogue
|
||||||
|
|
||||||
|
### Topics
|
||||||
|
|
||||||
|
<Route author="zoenglinghou" example="/chinadialogue/topics/cities" path="/chinadialogue/topics/:topic" :paramsDesc="['Topics']">
|
||||||
|
|
||||||
|
| Business | Cities | Climate Change | Conservation | Governance & Law | Health and Food | Natural Disasters | Pollution | Science & Tech | Security | Water |
|
||||||
|
| -------- | ------ | ------------------------- | ------------ | ------------------ | --------------- | ----------------- | --------- | ---------------- | -------- | ----- |
|
||||||
|
| business | cities | climate-change-and-energy | conservation | governance-and-law | health-and-food | natural-disasters | pollution | science-and-tech | security | water |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
### Columns
|
||||||
|
|
||||||
|
<Route author="zoenglinghou" example="/chinadialogue/article" path="/chinadialogue/:column" :paramsDesc="['栏目分类']">
|
||||||
|
|
||||||
|
| Articles | Blogs | Culture | Reports |
|
||||||
|
| -------- | ----- | ------- | ------- |
|
||||||
|
| article | blog | culture | reports |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## China Times
|
## China Times
|
||||||
|
|
||||||
### News
|
### News
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ category 对应的关键词有
|
|||||||
|
|
||||||
分类:
|
分类:
|
||||||
| zx | twhk | dwzw | zrdl | lskg | smyx | shbk | kjqy |
|
| zx | twhk | dwzw | zrdl | lskg | smyx | shbk | kjqy |
|
||||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
| ---- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||||
| 最新 | 天文航空 | 动物植物 | 自然地理 | 历史考古 | 生命医学 | 生活百科 | 科技前沿 |
|
| 最新 | 天文航空 | 动物植物 | 自然地理 | 历史考古 | 生命医学 | 生活百科 | 科技前沿 |
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
@@ -504,3 +504,25 @@ category 对应的关键词有
|
|||||||
| 即時 | 政治 | 言論 | 生活 | 娛樂 | 財經 | 社會 | 話題 | 快點 TV | 國際 | 軍事 | 兩岸 | 時尚 | 體育 | 科技 | 玩食 | 專輯 |
|
| 即時 | 政治 | 言論 | 生活 | 娛樂 | 財經 | 社會 | 話題 | 快點 TV | 國際 | 軍事 | 兩岸 | 時尚 | 體育 | 科技 | 玩食 | 專輯 |
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 中外对话
|
||||||
|
|
||||||
|
### 主题
|
||||||
|
|
||||||
|
<Route author="zoenglinghou" example="/chinadialogue/topics/cities" path="/chinadialogue/topics/:topic" :paramsDesc="['主题分类']">
|
||||||
|
|
||||||
|
| 商业 | 城市化 | 气候变化与能源 | 自然保护 | 管制与法律 | 健康与食品 | 自然灾害 | 污染 | 科学与技术 | 安全 | 水 |
|
||||||
|
| -------- | ------ | ------------------------- | ------------ | ------------------ | --------------- | ----------------- | --------- | ---------------- | -------- | ----- |
|
||||||
|
| business | cities | climate-change-and-energy | conservation | governance-and-law | health-and-food | natural-disasters | pollution | science-and-tech | security | water |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
### 栏目
|
||||||
|
|
||||||
|
<Route author="zoenglinghou" example="/chinadialogue/article" path="/chinadialogue/:column" :paramsDesc="['栏目分类']">
|
||||||
|
|
||||||
|
| 文章 | 博客 | 文化 | 报告 |
|
||||||
|
| ------- | ---- | ------- | ------- |
|
||||||
|
| article | blog | culture | reports |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|||||||
@@ -2142,4 +2142,8 @@ router.get('/apnews/topics/:topic', require('./routes/apnews/topics'));
|
|||||||
// discuz
|
// discuz
|
||||||
router.get('/discuz/:link', require('./routes/discuz/discuz'));
|
router.get('/discuz/:link', require('./routes/discuz/discuz'));
|
||||||
|
|
||||||
|
// China Dialogue 中外对话
|
||||||
|
router.get('/chinadialogue/topics/:topic', require('./routes/chinadialogue/topics'));
|
||||||
|
router.get('/chinadialogue/:column', require('./routes/chinadialogue/column'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
58
lib/routes/chinadialogue/column.js
Normal file
58
lib/routes/chinadialogue/column.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const column = ctx.params.column;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://www.chinadialogue.net/${column}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const list = $('article.main-listing');
|
||||||
|
let itemPicUrl;
|
||||||
|
let title;
|
||||||
|
let description;
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title').text(),
|
||||||
|
link: `https://www.chinadialogue.net/${column}`,
|
||||||
|
item:
|
||||||
|
list &&
|
||||||
|
list
|
||||||
|
.map((index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
itemPicUrl = item.find('img.img-responsive').attr('src');
|
||||||
|
|
||||||
|
title = [];
|
||||||
|
description = [];
|
||||||
|
|
||||||
|
item.find('h1').each(function(index, element) {
|
||||||
|
title.push(
|
||||||
|
$(element)
|
||||||
|
.text()
|
||||||
|
.replace(/(\r\n|\n|\r)/gm, '')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
item.find('p').each(function(index, element) {
|
||||||
|
description.push(
|
||||||
|
$(element)
|
||||||
|
.text()
|
||||||
|
.replace(/(\r\n|\n|\r)/gm, '')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: title.join(' | '),
|
||||||
|
description: `<p>${description.join('</p><p>')}</p><img src="${itemPicUrl}">`,
|
||||||
|
pubDate: item.find('time.blog').attr('datetime'),
|
||||||
|
link: item.find('a').attr('href'),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
};
|
||||||
|
};
|
||||||
55
lib/routes/chinadialogue/topics.js
Normal file
55
lib/routes/chinadialogue/topics.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const topic = ctx.params.topic;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://www.chinadialogue.net/topics/${topic}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const list = $('article.excerpt.col-md-6');
|
||||||
|
let itemPicUrl;
|
||||||
|
let title;
|
||||||
|
let description;
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title')
|
||||||
|
.text()
|
||||||
|
.replace(/( 主题 >| Topics >)/gm, ''),
|
||||||
|
link: `https://www.chinadialogue.net/topics/${topic}`,
|
||||||
|
item:
|
||||||
|
list &&
|
||||||
|
list
|
||||||
|
.map((index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
itemPicUrl = item.find('img.img-responsive').attr('src');
|
||||||
|
|
||||||
|
title = [];
|
||||||
|
description = [];
|
||||||
|
|
||||||
|
item.find('h1').each(function(index, element) {
|
||||||
|
title.push(
|
||||||
|
$(element)
|
||||||
|
.text()
|
||||||
|
.replace(/(\r\n|\n|\r)/gm, '')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
item.find('p').each(function(index, element) {
|
||||||
|
description.push($(element).text());
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: title.join(' | '),
|
||||||
|
description: `<p>${description.join('</p><p>')}</p><img src="${itemPicUrl}">`,
|
||||||
|
link: item.find('a').attr('href'),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user