From cfef5182ede7b7653cb8f03bec300e27bb186409 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Thu, 24 Dec 2020 01:50:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E5=8C=97=E5=B1=8B=20northhouse?= =?UTF-8?q?=20(#6494)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/new-media.md | 10 +++++++ lib/router.js | 3 ++ lib/routes/northhouse/index.js | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 lib/routes/northhouse/index.js diff --git a/docs/new-media.md b/docs/new-media.md index 00cdb1e64b..9a6558b6a0 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -666,6 +666,16 @@ Supported sub-sites: +## 北屋 + + + +| 首页 | 最新资讯和灾难信息 | 生存主义 survival | 运动户外 | 玩物尚志 | 分享下载 | 知行生活 | 商务服务 | +| ---- | ------------------ | ----------------- | -------- | -------- | -------- | -------- | -------- | +| | 最新资讯和灾难信息 | 生存主义 survival | 运动户外 | 玩物尚志 | 分享下载 | 知行生活 | 商务服务 | + + + ## 本地宝 ### 焦点资讯 diff --git a/lib/router.js b/lib/router.js index 36447f863d..f4927d6567 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3733,4 +3733,7 @@ router.get('/dayone/blog', require('./routes/dayone/blog')); // 滴答清单 router.get('/dida365/habit/checkins', require('./routes/dida365/habit-checkins')); +// 北屋 +router.get('/northhouse/:category?', require('./routes/northhouse/index')); + module.exports = router; diff --git a/lib/routes/northhouse/index.js b/lib/routes/northhouse/index.js new file mode 100644 index 0000000000..e6d55b2b5f --- /dev/null +++ b/lib/routes/northhouse/index.js @@ -0,0 +1,55 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const category = ctx.params.category || ''; + + const rootUrl = 'http://www.northhouse.cc'; + const currentUrl = `${rootUrl}${category === '' ? '' : `/category/${category}`}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data.replace(/
<\/div>/g, '