diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 3677c62130..fe851ee46d 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -2262,7 +2262,7 @@ }, ], }, - 'wenxuecity.com/': { + 'wenxuecity.com': { _name: '文学城', blog: [ { @@ -2276,6 +2276,9 @@ docs: 'https://docs.rsshub.app/bbs.html#wen-xue-cheng-bo-ke', source: '/myoverview/:id', target: 'wenxuecity/blog/:id', + }, + ], + }, 'buaq.net': { _name: '不安全资讯', '.': [ @@ -2287,4 +2290,15 @@ }, ], }, + 'jian-ning.com': { + _name: '建宁闲谈', + '.': [ + { + title: '文章', + docs: 'https://docs.rsshub.app/blog.html#jian-ning-xian-tan', + source: '/*', + target: '/blogs/jianning', + }, + ], + }, }); diff --git a/docs/blog.md b/docs/blog.md index ef6947dac4..b804287ac0 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -98,6 +98,12 @@ pageClass: routes +## 建宁闲谈 + +### 文章 + + + ## 敬维博客 ### 文章 diff --git a/docs/reading.md b/docs/reading.md index 1d627fa4e5..8224cb60ff 100644 --- a/docs/reading.md +++ b/docs/reading.md @@ -151,12 +151,6 @@ count 的取值范围为 1-12,为防止请求次数过多,推荐设置为 5 -## 孔夫子旧书网 - -### 用户动态 - - - ### 店铺上架 diff --git a/lib/router.js b/lib/router.js index 7c654d71b9..2926534193 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3185,4 +3185,7 @@ router.get('/secshi', require('./routes/secshi/index')); // 出海笔记 router.get('/chuhaibiji', require('./routes/chuhaibiji/index')); +// 建宁闲谈 +router.get('/blogs/jianning', require('./routes/blogs/jianning')); + module.exports = router; diff --git a/lib/routes/blogs/jianning.js b/lib/routes/blogs/jianning.js new file mode 100644 index 0000000000..3887cba075 --- /dev/null +++ b/lib/routes/blogs/jianning.js @@ -0,0 +1,45 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const iconv = require('iconv-lite'); +const url = require('url'); + +module.exports = async (ctx) => { + const base_url = `http://jian-ning.com/all-articles.html`; + const response = await got({ + method: 'get', + url: base_url, + responseType: 'buffer', + }); + const data = iconv.decode(response.data, 'gbk'); + const $ = cheerio.load(data); + const list = $('li'); + const out = list + .map(async (i, item) => { + const link = url.resolve('http://jian-ning.com', $(item).find('a').attr('href')); + const description = await ctx.cache.tryGet(link, async () => { + const result = await got({ + method: 'get', + url: link, + responseType: 'buffer', + headers: { + Referer: base_url, + }, + }); + const content = cheerio.load(iconv.decode(result.data, 'gbk')); + return content('td td').html(); + }); + const post = { + title: $(item).find('a').text(), + link: link, + pubDate: $(item).find('span').text(), + description: description, + }; + return post; + }) + .get(); + ctx.state.data = { + title: $('head > title').text(), + link: base_url, + item: await Promise.all(out), + }; +};