mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat: add diygod blog
This commit is contained in:
10
docs/blog.md
10
docs/blog.md
@@ -36,6 +36,16 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="aha2mao" example="/hexo/yilia/cloudstone.xin" path="/hexo/yilia/:url" :paramsDesc="['博客 Url 不带协议头']"/>
|
<Route author="aha2mao" example="/hexo/yilia/cloudstone.xin" path="/hexo/yilia/:url" :paramsDesc="['博客 Url 不带协议头']"/>
|
||||||
|
|
||||||
|
## Hi, DIYgod
|
||||||
|
|
||||||
|
### DIYgod 的动森日记
|
||||||
|
|
||||||
|
<Route author="DIYgod" example="/blogs/diygod/animal-crossing" path="/blogs/diygod/animal-crossing"/>
|
||||||
|
|
||||||
|
### DIYgod 的可爱的手办们
|
||||||
|
|
||||||
|
<Route author="DIYgod" example="/blogs/diygod/gk" path="/blogs/diygod/gk"/>
|
||||||
|
|
||||||
## LaTeX 开源小屋
|
## LaTeX 开源小屋
|
||||||
|
|
||||||
### 首页
|
### 首页
|
||||||
|
|||||||
@@ -2424,4 +2424,8 @@ router.get('/checkra1n/releases', require('./routes/checkra1n/releases'));
|
|||||||
// 四川省科学技术厅
|
// 四川省科学技术厅
|
||||||
router.get('/sckjt/news/:type?', require('./routes/sckjt/news'));
|
router.get('/sckjt/news/:type?', require('./routes/sckjt/news'));
|
||||||
|
|
||||||
|
// Hi, DIYgod
|
||||||
|
router.get('/blogs/diygod/animal-crossing', require('./routes/blogs/diygod/animal-crossing'));
|
||||||
|
router.get('/blogs/diygod/gk', require('./routes/blogs/diygod/gk'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
37
lib/routes/blogs/diygod/animal-crossing.js
Normal file
37
lib/routes/blogs/diygod/animal-crossing.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const date = require('@/utils/date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: 'https://diygod.me/animal-crossing',
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const list = $('h3');
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: 'DIYgod 的动森日记',
|
||||||
|
link: 'https://diygod.me/animal-crossing',
|
||||||
|
item:
|
||||||
|
list &&
|
||||||
|
list
|
||||||
|
.map((index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
let description = '';
|
||||||
|
item.nextUntil('h3').each((index, item) => {
|
||||||
|
description += $(item).html();
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
title: item.text(),
|
||||||
|
description,
|
||||||
|
link: `https://diygod.me/animal-crossing/#${item.attr('id')}`,
|
||||||
|
pubDate: date(item.text().split(' ')[1]),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
};
|
||||||
|
};
|
||||||
37
lib/routes/blogs/diygod/gk.js
Normal file
37
lib/routes/blogs/diygod/gk.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: 'https://diygod.me/gk',
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const list = $('.gk-item');
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: 'DIYgod 的动森日记',
|
||||||
|
link: 'https://diygod.me/animal-crossing',
|
||||||
|
item:
|
||||||
|
list &&
|
||||||
|
list
|
||||||
|
.map((index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const title = item
|
||||||
|
.find('.gk-desc p')
|
||||||
|
.eq(0)
|
||||||
|
.text()
|
||||||
|
.slice(3);
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
description: item.html(),
|
||||||
|
link: 'https://diygod.me/gk',
|
||||||
|
guid: title,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user