mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: Add China Dialogue (#3748)
This commit is contained in:
@@ -2142,4 +2142,8 @@ router.get('/apnews/topics/:topic', require('./routes/apnews/topics'));
|
||||
// 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;
|
||||
|
||||
@@ -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(),
|
||||
};
|
||||
};
|
||||
@@ -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