diff --git a/docs/other.md b/docs/other.md index 7a2be0fc3c..d3454d6148 100644 --- a/docs/other.md +++ b/docs/other.md @@ -367,6 +367,12 @@ type 为 all 时,category 参数不支持 cost 和 free +## 大侠阿木 + +### 首页 + + + ## 大众点评 ### 用户 diff --git a/lib/router.js b/lib/router.js index 1f536072b0..6987b5729b 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1512,6 +1512,9 @@ router.get('/ccdi/scdc', require('./routes/ccdi/scdc')); router.get('/nosetime/:id/:type/:sort?', require('./routes/nosetime/comment')); router.get('/nosetime/home', require('./routes/nosetime/home')); +// 大侠阿木 +router.get('/daxiaamu/home', require('./routes/daxiaamu/home')); + // 美团技术团队 router.get('/meituan/tech/home', require('./routes//meituan/tech/home')); diff --git a/lib/routes/daxiaamu/home.js b/lib/routes/daxiaamu/home.js new file mode 100644 index 0000000000..68b9470ea6 --- /dev/null +++ b/lib/routes/daxiaamu/home.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const parser = require('@/utils/rss-parser'); +const { addNoReferrer } = require('@/utils/common-utils'); + +module.exports = async (ctx) => { + const feed = await parser.parseURL('http://www.daxiaamu.com/rss'); + + const ProcessFeed = async (link) => { + const response = await got({ + method: 'get', + url: link, + }); + const $ = cheerio.load(response.data); + + addNoReferrer($, '.main-content'); + return $('.main-content').html(); + }; + + const items = await Promise.all( + feed.items.map(async (item) => { + const cache = await ctx.cache.get(item.link); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const description = await ProcessFeed(item.link); + + const single = { + title: item.title, + description, + pubDate: item.pubDate, + link: item.link, + author: item.author, + }; + ctx.cache.set(item.link, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + + ctx.state.data = { + title: feed.title, + link: feed.link, + description: feed.description, + item: items, + }; +};