fix: 刺猬猫RSS异常 #6170 (#6174)

This commit is contained in:
Laam Pui
2020-11-15 13:41:53 +00:00
committed by GitHub
parent 4fac4523df
commit 1cb4559e3d
+18 -13
View File
@@ -3,27 +3,32 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id;
const selector = cheerio.load((await got.get(`https://www.ciweimao.com/book/${id}`)).data);
const name = selector('.book-info h3.title').text();
const description = selector('.book-intro').html();
const response = await got({
method: 'get',
url: `http://www.ciweimao.com/chapter-list/${id}/book_detail`,
method: 'post',
url: `https://www.ciweimao.com/chapter/get_chapter_list_in_chapter_detail`,
form: {
book_id: id,
chapter_id: 0,
orderby: 0,
},
});
const $ = cheerio.load(response.data);
const name = $('.book-catalog>.hd>h3').text();
const chapter_item = [];
$('.book-chapter>.book-chapter-box>ul>li>a').each(function () {
chapter_item.push({
title: $(this).text(),
link: $(this).attr('href'),
});
});
const item = $('.book-chapter-box>ul>li>a')
.map((index, ele) => ({
title: $(ele).text(),
link: $(ele).attr('href'),
}))
.get();
ctx.state.data = {
title: `刺猬猫 ${name}`,
link: `http://www.ciweimao.com/book/${id}`,
item: chapter_item,
description,
item,
};
};