feat: 新增'观点网' (#11658)

* feat: 新增'观点网'

* polish
This commit is contained in:
drgnchan 2023-01-21 01:06:29 +08:00 committed by GitHub
parent 0d7f42e483
commit cf6dff4305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 0 deletions

View File

@ -2318,6 +2318,12 @@ others = 热点新闻 + 滚动新闻
<Route author="Jeason0228" example="/guancha/personalpage/243983" path="/guancha/personalpage/:uid" :paramsDesc="['用户id 可在URL中找到']" />
## 观点网
### 资讯
<Route author="drgnchan" example="/guandian/finance" path="/guandian/:category" :paramsDesc="['资讯分类可在URL中找到']" radar="1"/>
## 观海新闻
### 首页

37
lib/v2/guandian/index.js Normal file
View File

@ -0,0 +1,37 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const baseUrl = 'https://www.guandian.cn';
module.exports = async (ctx) => {
const cat = ctx.params.category;
const reqUrl = `${baseUrl}/${cat}/`;
const response = await got(reqUrl);
const $ = cheerio.load(response.data);
const items = $('.con_l li')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('.con_l_con_r a');
const link = a.attr('href');
const title = a.find('h3').text();
const desc = item.find('.con_l_con_r p').text();
const dateStr = item.find('#keyword span').text();
return {
title,
link,
description: desc,
pubDate: timezone(parseDate(dateStr), 8),
};
});
ctx.state.data = {
title: $('head title').text(),
link: reqUrl,
item: items,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/:category': ['drgnchan'],
};

11
lib/v2/guandian/radar.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = {
'guandian.cn': {
_name: '观点网',
www: {
title: '资讯',
docs: 'https://docs.rsshub.app/new-media.html#guan-dian-wang-zi-xun',
source: ['/:category'],
target: '/guandian/:category',
},
},
};

View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:category', require('./index'));
};