mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
feat: add naver webtoon (#3376)
This commit is contained in:
@@ -165,6 +165,10 @@ pageClass: routes
|
||||
|
||||
比如漫画公主彻夜未眠的网址为https://www.webtoons.com/zh-hant/drama/gongzhuweimian/list?title_no=894, 则`lang=zh-hant`,`category=drama`,`name=gongzhucheyeweimian`,`id=894`.
|
||||
|
||||
### [Naver](https://comic.naver.com)
|
||||
|
||||
<Route author="zfanta" example="/webtoons/naver/651673" path="/webtoons/naver/:titleId" :paramsDesc="['titleId']" />
|
||||
|
||||
## 嘀哩嘀哩 - dilidili
|
||||
|
||||
### 嘀哩嘀哩番剧更新
|
||||
|
||||
@@ -15,3 +15,9 @@ pageClass: routes
|
||||
| serial | finish |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Webtoons
|
||||
|
||||
### [Naver](https://comic.naver.com)
|
||||
|
||||
<RouteEn author="zfanta" example="/webtoons/naver/651673" path="/webtoons/naver/:titleId" :paramsDesc="['titleId of naver webtoon']" />
|
||||
|
||||
@@ -926,6 +926,7 @@ router.get('/vol/:mode?', require('./routes/vol/lastupdate'));
|
||||
router.get('/dongmanmanhua/:category/:name/:id', require('./routes/dongmanmanhua/comic'));
|
||||
// webtoons
|
||||
router.get('/webtoons/:lang/:category/:name/:id', require('./routes/webtoons/comic'));
|
||||
router.get('/webtoons/naver/:id', require('./routes/webtoons/naver'));
|
||||
|
||||
// Tits Guru
|
||||
router.get('/tits-guru/home', require('./routes/titsguru/home'));
|
||||
|
||||
50
lib/routes/webtoons/naver.js
Normal file
50
lib/routes/webtoons/naver.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const qs = require('querystring');
|
||||
const domain = 'https://comic.naver.com';
|
||||
|
||||
async function getDescription(ctx, link) {
|
||||
const { titleId, no } = qs.parse(link.substr(link.indexOf('?') + 1));
|
||||
const key = `webtoons/naver/${titleId}/${no}`;
|
||||
|
||||
let result = await ctx.cache.get(key);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const { body } = await got.get(link);
|
||||
const $ = cheerio.load(body);
|
||||
result = $('#comic_view_area > div.wt_viewer').html();
|
||||
ctx.cache.set(key, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
async function getItems(ctx, $) {
|
||||
return Promise.all(
|
||||
$('#content > table > tbody > tr')
|
||||
.toArray()
|
||||
.filter((ep) => !ep.attribs.class)
|
||||
.map(async (ep) => ({
|
||||
title: $('td.title > a', ep).text(),
|
||||
pubDate: new Date($('.num', ep).text()).toUTCString(),
|
||||
link: `${domain}${$('td.title > a', ep).attr('href')}`,
|
||||
description: await getDescription(ctx, `${domain}${$('td.title > a', ep).attr('href')}`),
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const comicLink = `${domain}/webtoon/list.nhn?titleId=${id}`;
|
||||
|
||||
const { body } = await got.get(comicLink);
|
||||
const $ = cheerio.load(body);
|
||||
const rss = {
|
||||
title: $('head title').text(),
|
||||
link: comicLink,
|
||||
description: $('#content > div.comicinfo > div.detail > p:nth-child(2)').text(),
|
||||
item: await getItems(ctx, $),
|
||||
};
|
||||
rss.item = rss.item.sort((a, b) => new Date(b.pubDate) - new Date(a.pubDate));
|
||||
ctx.state.data = rss;
|
||||
};
|
||||
Reference in New Issue
Block a user