feat(route): 爱果果-最新H5 (#9648)
* feat(route): 爱果果-最新H5 * Update lib/v2/iguoguo/radar.js * Update lib/v2/iguoguo/radar.js Co-authored-by: yuxinliu <yuxin2@mgtv.com>
This commit is contained in:
co-authored by
yuxinliu
parent
a428c4c5cd
commit
e21f09174c
@@ -194,6 +194,12 @@ Behance 用户主页 URL 获取用户名,如 <https://www.behance.net/mishapet
|
||||
|
||||
<Route author="MisteryMonster" example="/unit-image/films/vfx" path="/unit-image/films/:type?" :paramsDesc="['Films 下分类,`vfx`, `game-trailer`, `animation`, `commercials`, `making-of`']"/>
|
||||
|
||||
## 爱果果
|
||||
|
||||
### 最新H5
|
||||
|
||||
<Route author="yuxinliu-alex" example="/iguoguo/html5" path="/iguoguo/html5" />
|
||||
|
||||
## 优设网
|
||||
|
||||
### 设计专题
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const rootUrl = 'https://www.iguoguo.net';
|
||||
|
||||
const getChildrenFromCheerioRoot = (cheerioInstance) => {
|
||||
const root = cheerioInstance.root();
|
||||
const rootKeys = Object.keys(root).filter((n) => n % 1 === 0);
|
||||
const rootChildren = rootKeys.map((key) => root[key].children);
|
||||
return rootChildren[0];
|
||||
};
|
||||
|
||||
const getComments = (a, node) => {
|
||||
if (node.type === 'comment') {
|
||||
return a.concat([node.data]);
|
||||
} else if (node.type === 'tag' && node.children && node.children.length > 0) {
|
||||
return a.concat(node.children.reduce(getComments, []));
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = rootUrl.concat('/html5');
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('a', '.post')
|
||||
.filter((_, x) => $(x).attr('href').endsWith('.html'))
|
||||
.filter((_, x) => $(x).children().eq(0).attr('src'))
|
||||
.map((_, item) => ({
|
||||
link: $(item).attr('href'),
|
||||
cover: $(item).children().eq(0).attr('src'),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const mime = {
|
||||
jpg: 'jpeg',
|
||||
png: 'png',
|
||||
};
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
item.title = content('h1', '.post-info').text();
|
||||
item.description = content('div.clearfix', '.post_content').html();
|
||||
const comments = getChildrenFromCheerioRoot(content).reduce(getComments, []);
|
||||
const date = comments[comments.length - 1].trim().split(' ').slice(9, 11);
|
||||
item.pubDate = timezone(parseDate(date[0] + date[1], 'YYYY-MM-DDHH:mm:ss'), +8);
|
||||
item.media = {
|
||||
content: {
|
||||
url: item.cover,
|
||||
type: `image/${mime[item.cover.split('.').pop()]}`,
|
||||
},
|
||||
};
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: '爱果果',
|
||||
link: currentUrl,
|
||||
description: '爱果果iguoguo是一个优秀酷站、h5、UI素材资源的发布分享平台,是设计师的灵感聚合地和素材下载源。',
|
||||
language: 'zh-cn',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/html5': ['yuxinliu-alex'],
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
'iguoguo.net': {
|
||||
_name: '爱果果',
|
||||
'.': [
|
||||
{
|
||||
title: '最新H5',
|
||||
docs: 'https://docs.rsshub.app/design.html#ai-guo-guo-h5',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/html5', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user