From 1191d7fc498a2168f1300fc423e0c82c5dd5dfec Mon Sep 17 00:00:00 2001 From: Kode Date: Thu, 8 Aug 2019 22:53:03 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E7=AF=9D=E7=81=AB=E8=90=A5?= =?UTF-8?q?=E5=9C=B0=20(#2786)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/game.md | 16 +++++++++ lib/router.js | 4 +++ lib/routes/gouhuo/cache.js | 50 ++++++++++++++++++++++++++++ lib/routes/gouhuo/index.js | 62 +++++++++++++++++++++++++++++++++++ lib/routes/gouhuo/strategy.js | 37 +++++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 lib/routes/gouhuo/cache.js create mode 100644 lib/routes/gouhuo/index.js create mode 100644 lib/routes/gouhuo/strategy.js diff --git a/docs/game.md b/docs/game.md index 695fb5c686..90831878d1 100644 --- a/docs/game.md +++ b/docs/game.md @@ -141,6 +141,22 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 +## 篝火营地 + +### 游戏资讯 + + + +| 精选 | 海外 | 原创 | PS4 | Xboxone | PC | Switch | 掌机 | 手游 | 新闻 | 评测 | 文化 | 视频 | 音频 | 折扣 | +| ---------- | -------- | ------- | --- | ------- | --- | ------ | -------- | ---------- | ---- | ------ | ------- | ----- | ----- | -------- | +| choiceness | overseas | orignal | ps4 | xboxone | pc | switch | handheld | mobilegame | news | review | culture | video | audio | discount | + + + +### 游戏攻略 + + + ## 怪物猎人 ### 更新 diff --git a/lib/router.js b/lib/router.js index 867ecfbdbf..bb52f2aa1a 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1626,4 +1626,8 @@ router.get('/pingwest/user/:uid/:type?', require('./routes/pingwest/user')); // Hanime router.get('/hanime/video', require('./routes/hanime/video')); +// 篝火营地 +router.get('/gouhuo/news/:category', require('./routes/gouhuo')); +router.get('/gouhuo/strategy', require('./routes/gouhuo/strategy')); + module.exports = router; diff --git a/lib/routes/gouhuo/cache.js b/lib/routes/gouhuo/cache.js new file mode 100644 index 0000000000..680c130888 --- /dev/null +++ b/lib/routes/gouhuo/cache.js @@ -0,0 +1,50 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const self = { + _getProfile: async (ctx) => { + const key = 'gouhuo-profile'; + let profile = await ctx.cache.get(key); + if (!profile) { + const response = await got({ + method: 'get', + url: `https://gouhuo.qq.com/`, + headers: { + Referer: `https://gouhuo.qq.com/`, + }, + }); + const body = response.data; + const $ = cheerio.load(body); + + // eslint-disable-next-line no-eval + const obj = eval(body.match(/(?<=