From 2a925ef579761017b418951d9c613d6ee034c5ff Mon Sep 17 00:00:00 2001 From: mino Date: Wed, 10 Apr 2019 11:33:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20manhuagui=20=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E9=97=AE=E9=A2=98=20(#1904)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `.chapter-list` 下有多个 `ul`,最新的 `ul` 在最后面。 --- lib/routes/manhuagui/comic.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/routes/manhuagui/comic.js b/lib/routes/manhuagui/comic.js index 7923e562e..48f70f9eb 100644 --- a/lib/routes/manhuagui/comic.js +++ b/lib/routes/manhuagui/comic.js @@ -3,16 +3,26 @@ const cheerio = require('cheerio'); const axios = require('../../utils/axios'); const getChapters = ($) => - $('.chapter-list > ul li') - .map((_, ele) => { + $('.chapter-list > ul') + .toArray() + .reverse() + .reduce( + (acc, curr) => + acc.concat( + $(curr) + .children('li') + .toArray() + ), + [] + ) + .map((ele) => { const a = $(ele).children('a'); return { link: resolve('https://www.manhuagui.com/', a.attr('href')), title: a.attr('title'), num: a.find('i').text(), }; - }) - .toArray(); + }); module.exports = async (ctx) => { const { id } = ctx.params;