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, };