fix(route): baozimh selector (#12790)
This commit is contained in:
+1
-1
@@ -554,7 +554,7 @@ Sources
|
||||
|
||||
## 包子漫画
|
||||
|
||||
#### 订阅漫画
|
||||
### 订阅漫画
|
||||
|
||||
<Route author="Fatpandac" example="/baozimh/comic/guowangpaiming-shiricaofu" path="/baozimh/comic/:name" :paramsDesc="['漫画名称,在漫画链接可以得到(`comic/` 后的那段)']"/>
|
||||
|
||||
|
||||
+9
-14
@@ -9,11 +9,12 @@ module.exports = async (ctx) => {
|
||||
const name = ctx.params.name;
|
||||
const url = `${rootUrl}/comic/${name}`;
|
||||
|
||||
const response = await got.get(url);
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const comicTitle = $('div > div.pure-u-1-1.pure-u-sm-2-3.pure-u-md-3-4 > div > h1').text();
|
||||
const list = $('#layout > div.comics-detail > div:nth-child(3) > div > div:nth-child(4) > div')
|
||||
.map((_, item) => {
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
const title = $(item).find('span').text();
|
||||
const link = rootUrl + $(item).find('a').attr('href');
|
||||
|
||||
@@ -21,25 +22,18 @@ module.exports = async (ctx) => {
|
||||
title,
|
||||
link,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const directUrlParams = new URLSearchParams(new URL(item.link).search);
|
||||
const comicId = directUrlParams.get('comic_id');
|
||||
const sectionSolt = directUrlParams.get('section_slot');
|
||||
const chapterSlot = directUrlParams.get('chapter_slot');
|
||||
const descUrl = `https://www.webmota.com/comic/chapter/${comicId}/${sectionSolt}_${chapterSlot}.html`;
|
||||
|
||||
const detailResponse = await got.get(descUrl);
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
item.description = art(path.join(__dirname, 'templates/desc.art'), {
|
||||
imgUrlList: $('section.comic-contain')
|
||||
imgUrlList: $('.comic-contain')
|
||||
.find('amp-img')
|
||||
.map((_, item) => $(item).attr('src'))
|
||||
.get(),
|
||||
.toArray()
|
||||
.map((item) => $(item).attr('src')),
|
||||
});
|
||||
|
||||
return item;
|
||||
@@ -49,6 +43,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
ctx.state.data = {
|
||||
title: `包子漫画-${comicTitle}`,
|
||||
description: $('.comics-detail__desc').text(),
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user