diff --git a/README.md b/README.md index a2c6316dd..c875626ec 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 全国气象预警 - Gitlab - Explore +- 忧郁的弟弟 + - 文章 - 大连工业大学 - 教务处新闻 diff --git a/docs/README.md b/docs/README.md index ea9b547b6..acc7e7cf8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2212,3 +2212,13 @@ type,分类 | Trending | Most stars | All | | -------- | ---------- | --- | | trending | starred | all | + +## 忧郁的弟弟 + +### 文章 + +举例: [https://rsshub.app/mygalgame](https://rsshub.app/mygalgame) + +路由: `/mygalgame` + +参数: 无 diff --git a/router.js b/router.js index e931ad871..73a0a82a3 100755 --- a/router.js +++ b/router.js @@ -467,6 +467,9 @@ router.get('/weatherAlarm', require('./routes/weatherAlarm')); // Gitlab router.get('/gitlab/explore/:type', require('./routes/gitlab/explore')); +// 忧郁的弟弟 +router.get('/mygalgame', require('./routes/galgame/mygalgame')); + // DPU router.get('/dpu/jiaowu/:type?', require('./routes/dpu/jiaowu')); diff --git a/routes/galgame/mygalgame.js b/routes/galgame/mygalgame.js new file mode 100644 index 000000000..089563a57 --- /dev/null +++ b/routes/galgame/mygalgame.js @@ -0,0 +1,41 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const res = await axios({ + method: 'get', + url: 'https://www.mygalgame.com/', + header: { + Referer: 'https://www.mygalgame.com/', + }, + }); + + const data = res.data; + + const $ = cheerio.load(data); + const list = $('#article-list').find('.article'); + + ctx.state.data = { + title: $('title').text(), + link: 'https://www.mygalgame.com/', + description: '忧郁的弟弟 - Galgame资源发布站', + item: + list && + list + .slice(1) + .map((index, item) => { + item = $(item); + const time = `${item.find('.month').text()}${item.find('.day').text()}日`; + const date = new Date(); + const math = /(\d+)月(\d+)日/.exec(time); + + return { + title: item.find('h1').text(), + description: `${item.find('.info p').text()}`, + pubDate: new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]).toUTCString(), + link: item.find('h1 a').attr('href'), + }; + }) + .get(), + }; +};