mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(route): 每经网分类 (#7998)
* fix(route): 每经网分类 * refactor: migrate to v2 Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
+3
-3
@@ -2195,9 +2195,9 @@ router.get('/wineyun/:category', lazyloadRouteHandler('./routes/wineyun'));
|
||||
router.get('/xiaohongshu/user/:user_id/:category', lazyloadRouteHandler('./routes/xiaohongshu/user'));
|
||||
router.get('/xiaohongshu/board/:board_id', lazyloadRouteHandler('./routes/xiaohongshu/board'));
|
||||
|
||||
// 每经网
|
||||
router.get('/nbd/daily', lazyloadRouteHandler('./routes/nbd/article'));
|
||||
router.get('/nbd/:id?', lazyloadRouteHandler('./routes/nbd/index'));
|
||||
// 每经网 migrated to v2
|
||||
// router.get('/nbd/daily', lazyloadRouteHandler('./routes/nbd/article'));
|
||||
// router.get('/nbd/:id?', lazyloadRouteHandler('./routes/nbd/index'));
|
||||
|
||||
// 快知
|
||||
router.get('/kzfeed/topic/:id', lazyloadRouteHandler('./routes/kzfeed/topic'));
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'http://www.nbd.com.cn/columns/332';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
Referer: 'http://www.nbd.com.cn',
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $list = $('li.u-news-title').slice(0, 15).get();
|
||||
const description = $('head title').text().trim();
|
||||
|
||||
const resultItem = await Promise.all(
|
||||
$list.map(async (item) => {
|
||||
const title = $(item).find('a').text().trim();
|
||||
const pubDate = $(item).find('span').text().trim();
|
||||
const itemUrl = $(item).find('a').attr('href');
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
pubDate,
|
||||
description: '',
|
||||
};
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const detail = await got({
|
||||
method: 'get',
|
||||
url: itemUrl,
|
||||
headers: {
|
||||
Referer: 'http://www.nbd.com.cn',
|
||||
},
|
||||
});
|
||||
|
||||
{
|
||||
const $ = cheerio.load(detail.data);
|
||||
single.description = $('div.g-article').html();
|
||||
}
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '重磅原创-每经网',
|
||||
link: url,
|
||||
item: resultItem,
|
||||
description,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://www.nbd.com.cn/columns/332';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
Referer: 'https://www.nbd.com.cn',
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $list = $('li.u-news-title').slice(0, 15).get();
|
||||
const description = $('head title').text().trim();
|
||||
|
||||
const resultItem = await Promise.all(
|
||||
$list.map(async (item) => {
|
||||
const title = $(item).find('a').text().trim();
|
||||
const itemUrl = 'https:' + $(item).find('a').attr('href');
|
||||
|
||||
const single = await ctx.cache.tryGet(itemUrl, async () => {
|
||||
const detail = await got({
|
||||
method: 'get',
|
||||
url: itemUrl,
|
||||
headers: {
|
||||
Referer: 'https://www.nbd.com.cn',
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(detail.data);
|
||||
return {
|
||||
title,
|
||||
link: itemUrl,
|
||||
pubDate: timezone(parseDate(detail.data.match(/"pubDate": "(.*)"/)[1]), +8),
|
||||
description: $('div.g-article').html(),
|
||||
};
|
||||
});
|
||||
return single;
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '重磅原创-每经网',
|
||||
link: url,
|
||||
item: resultItem,
|
||||
description,
|
||||
};
|
||||
};
|
||||
@@ -1,11 +1,14 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id || '3';
|
||||
const id = ctx.params.id ?? '3';
|
||||
|
||||
const rootUrl = 'http://www.nbd.com.cn';
|
||||
const rootUrl = 'https://www.nbd.com.cn';
|
||||
const currentUrl = `${rootUrl}/columns/${id}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
@@ -14,12 +17,12 @@ module.exports = async (ctx) => {
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.u-news-title a')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
link: 'https:' + item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
@@ -34,7 +37,7 @@ module.exports = async (ctx) => {
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.g-articl-text').html();
|
||||
item.pubDate = new Date(detailResponse.data.match(/"pubDate": "(.*)"/)[1]).toUTCString();
|
||||
item.pubDate = timezone(parseDate(detailResponse.data.match(/"pubDate": "(.*)"/)[1]), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/daily': ['MeXunco'],
|
||||
'/:id?': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'nbd.com.cn': {
|
||||
_name: '每经网',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/finance.html#mei-jing-wang',
|
||||
source: '/',
|
||||
targer: '/nbd',
|
||||
},
|
||||
{
|
||||
title: '重磅原创',
|
||||
docs: 'https://docs.rsshub.app/finance.html#mei-jing-wang',
|
||||
source: '/',
|
||||
targer: '/nbd/daily',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/daily', require('./article'));
|
||||
router.get('/:id?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user