diff --git a/docs/picture.md b/docs/picture.md index 4ebf461428..f996c88cb9 100644 --- a/docs/picture.md +++ b/docs/picture.md @@ -179,6 +179,14 @@ pageClass: routes | ------ | ---------- | | ooxx | top-ooxx | +## 绝对领域 + + + +| 图集 | 文章 | +| ---- | ---- | +| tuji | as | + ## 妹子图 ### 首页(最新) diff --git a/lib/router.js b/lib/router.js index 15df59f6a5..374cf47f0d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2496,6 +2496,9 @@ router.get('/checkra1n/releases', require('./routes/checkra1n/releases')); // 四川省科学技术厅 router.get('/sckjt/news/:type?', require('./routes/sckjt/news')); +// 绝对领域 +router.get('/jdlingyu/:type', require('./routes/jdlingyu/index')); + // Hi, DIYgod router.get('/blogs/diygod/animal-crossing', require('./routes/blogs/diygod/animal-crossing')); router.get('/blogs/diygod/gk', require('./routes/blogs/diygod/gk')); diff --git a/lib/routes/jdlingyu/index.js b/lib/routes/jdlingyu/index.js new file mode 100644 index 0000000000..1bf70e3562 --- /dev/null +++ b/lib/routes/jdlingyu/index.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const baseUrl = 'https://www.jdlingyu.mobi/'; +const viewProps = { + tuji: '图集', + as: '文章', +}; + +module.exports = async (ctx) => { + const type = ctx.params.type || 'tuji'; + const url = baseUrl + type; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + + const items = await Promise.all( + $('#main > div.grid-bor > div') + .get() + .map(async (div) => { + const a = $(div).find('.entry-title > a'); + const link = a.attr('href'); + const description = await ctx.cache.tryGet(link, async () => { + const response = await got.get(link); + const $ = cheerio.load(response.data); + return $('#content-innerText > p').html(); + }); + return Promise.resolve({ + title: a.text(), + description: description, + author: $(div) + .find('.post-header .users') + .text(), + link: link, + pubDate: new Date( + $(div) + .find('.post-header time') + .attr('datetime') + ).toUTCString(), + }); + }) + ); + ctx.state.data = { + title: `${viewProps[type]} - 绝对领域`, + link: url, + description: `${viewProps[type]} - 绝对领域`, + item: items, + }; +};