fix: 才府社区用户动态链接 (#5607)

Co-authored-by: codefactor-io <support@codefactor.io>
This commit is contained in:
Ethan Shen 2020-09-06 04:00:07 +08:00 committed by GitHub
parent 23e78dda49
commit def39c915a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 4 deletions

View File

@ -7,17 +7,32 @@ module.exports = async (ctx) => {
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('div.dynamic-single')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const word = item.find('div.word');
const detailTitle = item.find('p.detail-title').text();
let link = currentUrl;
let title = detailTitle || word.html();
if (word.attr('onclick')) {
link = `https://sns.91ddcc.com${word.attr('onclick').split("'")[1]}`;
} else {
title = item.find('div.fl').text().trim();
}
item.find('p.detail-title').remove();
return {
title: item.find('div.detail-time').text(),
link: `https://sns.91ddcc.com/${item.attr('id').split('-')[1]}`,
description: word.html(),
pubDate: new Date(item.find('div.detail-time').text() + ' GMT+8').toUTCString(),
title: title,
link: link,
description: item.find('div.dynamic-content').html(),
pubDate: new Date(item.attr('add-time') * 1000).toUTCString(),
};
})
.get();