From 0d2cc88e2c8642ab2a056034d2a16488fd68bbbf Mon Sep 17 00:00:00 2001 From: junfengP <840282629@qq.com> Date: Fri, 23 Oct 2020 23:33:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=BC=AB=E5=B0=8F=E8=82=86=20host=20?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=20(#5973)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: junfeng --- assets/radar-rules.js | 2 +- lib/routes/manxiaosi/book.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 95ee4c7fe..ced4d2191 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -2293,7 +2293,7 @@ }, ], }, - 'pknbc.com': { + 'jjmhw.cc': { _name: '漫小肆', www: [ { diff --git a/lib/routes/manxiaosi/book.js b/lib/routes/manxiaosi/book.js index bdb1f7433..f7fe949b4 100644 --- a/lib/routes/manxiaosi/book.js +++ b/lib/routes/manxiaosi/book.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const host = 'http://www.pknbc.com'; +const host = 'http://www.jjmhw.cc'; +const ua = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Mobile Safari/537.36'; module.exports = async (ctx) => { const id = ctx.params.id; @@ -18,9 +19,14 @@ module.exports = async (ctx) => { link: itemLink, }; const details = await ctx.cache.tryGet(itemLink, async () => { - const response = await got.get(itemLink); + // 具体页面限制手机UA + const response = await got.get(itemLink, { + headers: { + 'user-agent': ua, + }, + }); const $ = cheerio.load(response.body); - const imgs = $('div.comicpage img'); + const imgs = $('div#cp_img img'); let pics = ''; imgs.each((_, ele) => { const $ele = $(ele);