fix: update links of 爱Q生活网 (#5856)

Co-authored-by: codefactor-io <support@codefactor.io>
This commit is contained in:
Ethan Shen 2020-10-18 09:43:01 +08:00 committed by GitHub
parent 282c890659
commit be27e9f10d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 10 deletions

View File

@ -3,24 +3,21 @@ const cheerio = require('cheerio');
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
const rootUrl = 'https://www.3k8.com';
const currentUrl = `${rootUrl}/post/new_100/`;
const rootUrl = 'https://wap.3k8.com';
const response = await got({
method: 'get',
url: currentUrl,
url: rootUrl,
responseType: 'buffer',
});
const $ = cheerio.load(iconv.decode(response.data, 'gb2312'));
const list = $('ul.list-item li')
const list = $('div.one-img-plc')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a');
return {
title: a.attr('title'),
link: rootUrl + a.attr('href'),
link: rootUrl + item.find('a').attr('href'),
};
})
.get();
@ -37,8 +34,9 @@ module.exports = async (ctx) => {
const content = cheerio.load(iconv.decode(detailResponse.data, 'gb2312'));
item.pubDate = new Date(content('span.time').text() + ' GMT+8').toUTCString();
item.description = content('div.content-intro').html();
item.title = content('h1.title').text();
item.pubDate = new Date(content('div.news-mes span').eq(0).text().replace('发布时间:', '').trim() + ' GMT+8').toUTCString();
item.description = content('div.news-content').html();
return item;
})
@ -47,7 +45,7 @@ module.exports = async (ctx) => {
ctx.state.data = {
title: '爱Q生活网 - 最近更新',
link: currentUrl,
link: rootUrl,
item: items,
};
};