mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
Adding GoComics.com and ComicsKingdom.com
This commit is contained in:
@@ -42,6 +42,10 @@ pageClass: routes
|
||||
|
||||
<RouteEn author="FHYunCai" example="/bing" path="/bing" radar="1" rssbud="1"/>
|
||||
|
||||
## ComicsKingdom Comic Strips
|
||||
|
||||
<RouteEn author="stjohnjohnson" example="/comicskingdom/baby-blues" path="/comicskingdom/:strip" :paramsDesc="['URL path of the strip on comicskingdom.com']" />
|
||||
|
||||
## DailyArt
|
||||
|
||||
<RouteEn author="zphw" example="/dailyart/en" path="/dailyart/:language?" :paramsDesc="['Support en, es, fr, de, it, zh, jp, etc. English by default.']" />
|
||||
@@ -50,6 +54,10 @@ pageClass: routes
|
||||
|
||||
<RouteEn name="Daily Strip" author="Maecenas" example="/dilbert/strip" path="/dilbert/strip"/>
|
||||
|
||||
## GoComics Comic Strips
|
||||
|
||||
<RouteEn author="stjohnjohnson" example="/gocomics/foxtrot" path="/gocomics/:strip" :paramsDesc="['URL path of the strip on gocomics.com']" />
|
||||
|
||||
## Google Doodles
|
||||
|
||||
### Update
|
||||
|
||||
@@ -3780,4 +3780,10 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
|
||||
// Caixin Latest
|
||||
router.get('/caixin/latest', require('./routes/caixin/latest'));
|
||||
|
||||
// GoComics
|
||||
router.get('/gocomics/:name', require('./routes/gocomics/index'));
|
||||
|
||||
// Comics Kingdom
|
||||
router.get('/comicskingdom/:name', require('./routes/comicskingdom/index'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
62
lib/routes/comicskingdom/index.js
Normal file
62
lib/routes/comicskingdom/index.js
Normal file
@@ -0,0 +1,62 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseURL = 'https://www.comicskingdom.com';
|
||||
const name = ctx.params.name;
|
||||
const url = `${baseURL}/${name}/archive`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
// Determine Comic and Author from main page
|
||||
const comic = $('title').text().replace('Comics Kingdom - ', '').trim();
|
||||
const author = $('div.author p').text();
|
||||
|
||||
// Find the links for all non-archived items
|
||||
const links = $('div.archive-tile[data-is-blocked=false]')
|
||||
.map((i, el) => $(el).find('a[data-prem="Comic Tile"]').first().attr('href'))
|
||||
.get()
|
||||
.map((url) => `${baseURL}${url}`);
|
||||
|
||||
if (links.length === 0) {
|
||||
throw `Comic Not Found - ${name}`;
|
||||
}
|
||||
const items = await Promise.all(
|
||||
links.map(
|
||||
async (link) =>
|
||||
await ctx.cache.tryGet(link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
const title = content('title').text();
|
||||
const image = content('meta[property="og:image"]').attr('content');
|
||||
const description = `<img src="${image}" />`;
|
||||
// Pull the date out of the URL
|
||||
const pubDate = new Date(link.split('/').slice(-3).join('/')).toUTCString();
|
||||
|
||||
return {
|
||||
title: title,
|
||||
author: author,
|
||||
category: 'comic',
|
||||
description: description,
|
||||
pubDate: pubDate,
|
||||
link: link,
|
||||
};
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${comic} - Comics Kingdom`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
64
lib/routes/gocomics/index.js
Normal file
64
lib/routes/gocomics/index.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseURL = 'https://www.gocomics.com';
|
||||
const name = ctx.params.name;
|
||||
const limit = ctx.query.limit || 5;
|
||||
const url = `${baseURL}/${name}/`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
// Determine Comic and Author from main page
|
||||
const comic = $('.media-heading').eq(0).text();
|
||||
const author = $('.media-subheading').eq(0).text().replace('By ', '');
|
||||
|
||||
// Load previous comic URL
|
||||
const items = [];
|
||||
let previous = $('.gc-deck--cta-0 a').attr('href');
|
||||
|
||||
if (!previous) {
|
||||
throw `Comic Not Found - ${name}`;
|
||||
}
|
||||
|
||||
while (items.length < limit) {
|
||||
const link = `${baseURL}${previous}`;
|
||||
/* eslint-disable no-await-in-loop */
|
||||
const item = await ctx.cache.tryGet(link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
const title = content('h1.m-0').eq(0).text();
|
||||
const image = content('.comic.container').eq(0).attr('data-image');
|
||||
const description = `<img src="${image}" />`;
|
||||
// Pull the date out of the URL
|
||||
const pubDate = new Date(link.split('/').slice(-3).join('/')).toUTCString();
|
||||
const previous = content('.js-previous-comic').eq(0).attr('href');
|
||||
|
||||
return {
|
||||
title: title,
|
||||
author: author,
|
||||
category: 'comic',
|
||||
description: description,
|
||||
pubDate: pubDate,
|
||||
link: link,
|
||||
previous: previous,
|
||||
};
|
||||
});
|
||||
items.push(item);
|
||||
previous = item.previous;
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: `${comic} - GoComics`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user