fix(route): guanhai (#14337)

This commit is contained in:
Tony 2024-01-29 04:28:11 +08:00 committed by GitHub
parent 00fecf46fc
commit 7412e9ef5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 10 deletions

View File

@ -7,12 +7,16 @@ module.exports = async (ctx) => {
const { data: response } = await got('https://www.guanhai.com.cn');
const $ = cheerio.load(response);
const imgBox = $('.img-box');
const recommand = {
title: imgBox.find('a').first().attr('title'),
link: imgBox.find('a').first().attr('href'),
pubDate: timezone(parseDate(imgBox.find('time').text()), 8),
};
const recommand = $('.img-box ul > a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.attr('title'),
link: item.attr('href'),
};
});
const list = [
...$('.pic-summary .title')
.toArray()
@ -21,11 +25,11 @@ module.exports = async (ctx) => {
return {
title: item.find('a').attr('title'),
link: item.find('a').attr('href'),
pubDate: timezone(parseDate(item.find('time').text()), 8),
pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8),
};
}),
recommand,
];
...recommand,
].filter((item) => item.link.startsWith('http'));
const items = await Promise.all(
list.map((item) =>
@ -33,7 +37,8 @@ module.exports = async (ctx) => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
item.author = $('.source').text();
item.description = $('.article-content').html();
item.description = $('.article-content').html() ?? $('.video-content').html();
item.pubDate = item.pubDate ?? timezone(parseDate($('.date').text(), 'YYYY-MM-DD HH:mm'), 8);
return item;
})
)