From f29094db96d4bf191e7549371f52421bd5ada800 Mon Sep 17 00:00:00 2001 From: auto-bot-ty <75887908+auto-bot-ty@users.noreply.github.com> Date: Sat, 3 Sep 2022 23:57:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E8=B5=B7=E7=82=B9=20=E7=AB=A0?= =?UTF-8?q?=E8=8A=82=20(#10693)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix /qidian/chapter * fix /qidian/chapter * delete gitpod.yml * fix: name parsing Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> --- lib/v2/qidian/chapter.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/v2/qidian/chapter.js b/lib/v2/qidian/chapter.js index f1f806386a..8bdfeceb1f 100644 --- a/lib/v2/qidian/chapter.js +++ b/lib/v2/qidian/chapter.js @@ -5,15 +5,14 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { const id = ctx.params.id; - const response = await got(`https://book.qidian.com/info/${id}/#Catalog`); + const response = await got(`https://m.qidian.com/book/${id}.html`); const $ = cheerio.load(response.data); - const name = $('.book-info>h1>em').text(); - const cover_url = 'https:' + $('#bookImg>img').attr('src'); + const name = $('.book-detail-info .book-title').text(); + const cover_url = 'https:' + $('.book-detail-info img').attr('src'); - const csrfToken = response.headers['set-cookie'].find((s) => s.startsWith('_csrfToken=')).split(';')[0]; - - const chapters_response = await got(`https://book.qidian.com/ajax/book/category?${csrfToken}&bookId=${id}`); + const csrfToken = await got(`https://m.qidian.com/book/${id}/catalog/`).then((res) => res.headers['set-cookie'].join('').match(/_csrfToken=(\S*);/)[0]); + const chapters_response = await got(`https://m.qidian.com/majax/book/category?${csrfToken}&bookId=${id}`); const chapter_item = []; for (let i = 0; i < chapters_response.data.data.vs.length; i++) { @@ -31,7 +30,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: `起点 ${name}`, link: `https://book.qidian.com/info/${id}`, - description: $('.book-info>p.intro').text(), + description: $('#bookSummary content').text(), image: cover_url, item: chapter_item, };