feat(route): 首席经济学家论坛 (#9550)

* add(route): 首席经济学家论坛

* fix(route) : merge from FledgeXu

* fix(route) : merge from FledgeXu

* (fix) typo

* feat(route): remove radar from radar-rules.js

* Update lib/v2/chinacef/hot.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/chinacef/router.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/chinacef/maintainer.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/chinacef/experts.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/chinacef/experts.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update hot.js

* Update experts.js

Co-authored-by: linkai <linkai@mochasoft.com.cn>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
kdan 2022-04-16 23:30:10 +08:00 committed by GitHub
parent 08c1a032aa
commit 5622641efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 137 additions and 1 deletions

View File

@ -243,6 +243,20 @@ pageClass: routes
<Route author="FledgeXu" example="/chinacef" path="/chinacef"/>
### 专家
<Route author="kdanfly" example="/chinacef/17" path="/chinacef/:experts_id" :paramsDesc="['专家编号']" radar="1" rssbud="1">
| 李迅雷 | 夏斌 |
| --- | -- |
| 17 | 35 |
</Route>
### 金融热点
<Route author="kdanfly" example="/chinacef/portal/hot" path="/chinacef/portal/hot" radar="1" rssbud="1" />
## 淘股吧股票论坛
### 论坛总版

View File

@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { art } = require('@/utils/render');
const path = require('path');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got(`http://www.chinacef.cn/index.php/experts/zjmain/experts_id/${ctx.params.experts_id}`);
const data = response.data;
const $ = cheerio.load(data);
const domArray = $('div[class^="leftnews"]');
const itemAuthor = $('div[class=right515name] h3').text().trim();
const siteLink = 'http://www.chinacef.cn';
const rssTitle = $('title').text().trim();
const itemArray = await Promise.all(
domArray
.filter((index, item) => undefined !== $(item).find('h2 > a').attr('href'))
.map(async (index, item) => {
item = $(item);
const itemLink = siteLink + item.find('h2 > a').attr('href');
const detail = await ctx.cache.tryGet(itemLink, async () => {
const result = await got.get(itemLink);
const $ = cheerio.load(result.data);
const description = art(path.join(__dirname, 'templates/work_description.art'), {
desc: $('.newsmaintext').first().html().trim(),
});
return {
title: $('.contenttitle').first().html().trim(),
article: description,
};
});
return {
title: detail.title,
description: detail.article,
link: itemLink,
pubDate: parseDate(item.find('span').first().text(), 'YYYY-MM-DD'),
author: itemAuthor,
};
})
);
ctx.state.data = {
title: rssTitle,
link: siteLink,
item: itemArray,
};
};

53
lib/v2/chinacef/hot.js Normal file
View File

@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { art } = require('@/utils/render');
const path = require('path');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got.get('http://www.chinacef.cn/index.php/index/index');
const data = response.data;
const $ = cheerio.load(data);
const domArray = $('#boardright ul');
const siteLink = 'http://www.chinacef.cn';
const rssTitle = '金融热点 - 首席经济学家论坛';
const itemArray = await Promise.all(
domArray
.map(async (index, item) => {
item = $(item);
const itemLink = siteLink + item.find('li a').attr('href');
const detail = await ctx.cache.tryGet(itemLink, async () => {
const result = await got.get(itemLink);
const $ = cheerio.load(result.data);
const description = art(path.join(__dirname, 'templates/work_description.art'), {
desc: $('.newsmaintext').first().html().trim(),
});
return {
title: $('.contenttitle').first().html().trim(),
author: $('.zzinfo').find('h2').first().text().trim(),
pubDate: parseDate($('.divwidth').text().trim().split(' ')[3], 'YYYY-MM-DD'),
article: description,
};
});
return {
title: detail.title,
description: detail.article,
link: itemLink,
pubDate: detail.pubDate,
author: detail.author,
};
})
.get()
);
ctx.state.data = {
title: rssTitle,
link: siteLink,
item: itemArray,
};
};

View File

@ -1,3 +1,5 @@
module.exports = {
'/chinacef': ['FledgeXu'],
'/': ['FledgeXu'],
'/:experts_id': ['kdanfly'],
'/portal/hot': ['kdanfly'],
};

View File

@ -8,6 +8,18 @@ module.exports = {
source: ['/'],
target: '/chinacef',
},
{
title: '专家文章',
docs: 'https://docs.rsshub.app/finance.html#shou-xi-jing-ji-xue-jia-lun-tan-zhuan-jia',
source: ['/index.php/experts/zjmain/experts_id/:experts_id'],
target: '/chinacef/:experts_id',
},
{
title: '金融热点',
docs: 'https://docs.rsshub.app/finance.html#shou-xi-jing-ji-xue-jia-lun-tan-jin-rong-re-dian',
source: ['/index.php/index/index'],
target: '/chinacef/portal/hot',
},
],
},
};

View File

@ -1,3 +1,5 @@
module.exports = function (router) {
router.get('/:experts_id', require('./experts'));
router.get('/portal/hot', require('./hot'));
router.get('/', require('./index'));
};

View File

@ -0,0 +1 @@
<div>{{ desc }}</div>