fix: 动漫狂添加herder referer;rss正文输出为全部内容 (#2091)
* fix: 动漫狂添加herder referer;rss正文输出为全部内容
This commit is contained in:
parent
31fb2a7224
commit
98afb19529
|
|
@ -3,16 +3,25 @@ const cheerio = require('cheerio');
|
|||
const axios = require('../../utils/axios');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
const getChapters = ($) =>
|
||||
const getChapters = (id, $) =>
|
||||
$('#info')
|
||||
.eq(1)
|
||||
.find('a')
|
||||
.map((_, ele) => {
|
||||
const a = $(ele);
|
||||
const link = resolve('https://www.cartoonmad.com/', a.attr('href'));
|
||||
const title = a.text();
|
||||
const num = a.next('font').text();
|
||||
let contentBody = '';
|
||||
for (let page = 1; page <= parseInt(/\d+/.exec(num)); page++) {
|
||||
contentBody += `<img referrerpolicy="no-referrer" src="http://web.cartoonmad.com/home75458/${id}/${title.split(' ')[1]}/${(Array(3).join(0) + page).slice(-3)}.jpg" /></br>`;
|
||||
}
|
||||
|
||||
return {
|
||||
link: resolve('https://www.cartoonmad.com/', a.attr('href')),
|
||||
title: a.text(),
|
||||
num: a.next('font').text(),
|
||||
link,
|
||||
title,
|
||||
num,
|
||||
contentBody,
|
||||
};
|
||||
})
|
||||
.toArray()
|
||||
|
|
@ -21,7 +30,13 @@ const getChapters = ($) =>
|
|||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
|
||||
const { data } = await axios.get(`https://www.cartoonmad.com/comic/${id}`, { responseType: 'arraybuffer' });
|
||||
const { data } = await axios.get(`https://www.cartoonmad.com/comic/${id}`, {
|
||||
responseType: 'arraybuffer',
|
||||
headers: {
|
||||
Host: 'www.cartoonmad.com',
|
||||
Referer: 'https://www.cartoonmad.com/',
|
||||
},
|
||||
});
|
||||
const content = iconv.decode(new Buffer.from(data), 'big5');
|
||||
const $ = cheerio.load(content);
|
||||
|
||||
|
|
@ -33,19 +48,16 @@ module.exports = async (ctx) => {
|
|||
.find('td')
|
||||
.text()
|
||||
.trim();
|
||||
const coverImgSrc = $('.cover')
|
||||
.parent()
|
||||
.find('img')
|
||||
.attr('src');
|
||||
const chapters = getChapters($);
|
||||
// const coverImgSrc = $('.cover')
|
||||
// .parent()
|
||||
// .find('img')
|
||||
// .attr('src');
|
||||
const chapters = getChapters(id, $);
|
||||
|
||||
const genResult = (chapter) => ({
|
||||
link: chapter.link,
|
||||
title: chapter.title,
|
||||
description: `
|
||||
<h1>${chapter.num}</h1>
|
||||
<img referrerpolicy="no-referrer" src="${coverImgSrc}" />
|
||||
`.trim(),
|
||||
description: chapter.contentBody,
|
||||
});
|
||||
ctx.state.data = {
|
||||
title: `動漫狂 - ${bookTitle}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue