mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
* Fix(route): fix route is empty and change to V2 * Fix(route): route address err in maintainer.js * Fix(route): change way to get pubDate * Fix(route): add timezone
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const timezone = require('@/utils/timezone');
|
|
|
|
const rootUrl = 'https://www.ccreports.com.cn';
|
|
|
|
module.exports = async (ctx) => {
|
|
const listData = await got.get(rootUrl);
|
|
const $ = cheerio.load(listData.data);
|
|
const list = $('div.index-four-content > div.article-box')
|
|
.find('div.new-child')
|
|
.map((_, item) => ({
|
|
title: $(item).find('p.new-title').text(),
|
|
link: new URL($(item).find('a').attr('href'), rootUrl).href,
|
|
author: $(item)
|
|
.find('p.new-desc')
|
|
.text()
|
|
.match(/作者:(.*?)\s/)[1],
|
|
}))
|
|
.get();
|
|
|
|
const items = await Promise.all(
|
|
list.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
const detailData = await got.get(item.link);
|
|
const $ = cheerio.load(detailData.data);
|
|
item.description = $('div.pdbox').html();
|
|
item.pubDate = timezone(parseDate($('div.newbox > div.newtit > p').text(), 'YYYY-MM-DD HH:mm:ss'), +8);
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: '消费者报道',
|
|
link: rootUrl,
|
|
item: items,
|
|
};
|
|
};
|