fix: zzz can't get content (#3129)

This commit is contained in:
Cloud 2019-09-25 11:58:21 +08:00 committed by DIYgod
parent 92f4092e94
commit dc95d73863
1 changed files with 5 additions and 12 deletions

View File

@ -4,16 +4,12 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got.get('https://z-z-z.vip');
const $ = cheerio.load(response.data);
const list = $('.media-list .az-article-wrapper').get();
const list = $('.posts-wrapper article').get();
const ProcessFeed = (data) => {
const $ = cheerio.load(data);
const content = $('div.bpp-post-content');
content.find('img').each((i, e) => {
$(e).attr('src', $(e).attr('data-echo'));
});
const content = $('.nv-content-wrap.entry-content');
return content.html();
};
@ -21,7 +17,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);
const $a = $('.media-heading a');
const $a = $('.blog-entry-title a');
const link = $a.attr('href');
const cache = await ctx.cache.get(link);
@ -38,11 +34,8 @@ module.exports = async (ctx) => {
title: $a.text(),
description: ProcessFeed(response.data),
link: link,
pubDate: $('.glyphicon-calendar')
.toArray()[0]
.nextSibling.data.replace(/年|月/g, '-')
.replace('日', ''),
author: $('.glyphicon-user').toArray()[0].nextSibling.data,
pubDate: new Date($('time.published').attr('datetime')).toUTCString(),
author: $('.author-name > a').text(),
};
ctx.cache.set(link, JSON.stringify(single));