diff --git a/lib/routes/novel/zhaishuyuan.js b/lib/routes/novel/zhaishuyuan.js index aaefaedf9..482fcd0af 100644 --- a/lib/routes/novel/zhaishuyuan.js +++ b/lib/routes/novel/zhaishuyuan.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const id = ctx.params.id; const url = 'https://www.zhaishuyuan.com'; const link = `${url}/book/${id}`; - let extendedGot = got.extend({ headers: { Referer: url }, responseType: 'buffer' }); + const extendedGot = got.extend({ headers: { Referer: url }, responseType: 'buffer' }); const response = await extendedGot.get(link); const html = iconv.decode(response.data, 'gb2312'); const $ = cheerio.load(html); @@ -17,13 +17,16 @@ module.exports = async (ctx) => { .find('a') .map((_, { attribs: { title, href } }) => ({ title, link: `${url}${href}` })) .get(); - extendedGot = got.extend({ headers: { Referer: link }, responseType: 'buffer' }); const item = await Promise.all( list.map( async ({ title, link }) => await ctx.cache.tryGet(link, async () => { - const response = await extendedGot.get(link); - const html = iconv.decode(response.data, 'gb2312'); + const browser = await require('@/utils/puppeteer')(); + const page = await browser.newPage(); + await page.goto(link); + const encoded = await page.$('#content > div > a'); + await encoded.evaluate((encoded) => encoded.click()); + const html = await page.evaluate(() => document.documentElement.innerHTML); const $ = cheerio.load(html); const content = $('#content'); content.find('div').remove();