From 606eb6342b4a81ef1585d0c9cf90314aa4aeb443 Mon Sep 17 00:00:00 2001 From: Chenyang Shi Date: Sun, 12 May 2019 15:14:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E4=B8=AD=E5=9B=BD=E9=93=B6?= =?UTF-8?q?=E8=A1=8C=E5=A4=96=E6=B1=87=E7=89=8C=E4=BB=B7=20(#2103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/other.md | 4 ++++ lib/router.js | 3 +++ lib/routes/boc/whpj.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/routes/boc/whpj.js diff --git a/docs/other.md b/docs/other.md index f4053b2d7c..71e26439ff 100644 --- a/docs/other.md +++ b/docs/other.md @@ -555,6 +555,10 @@ type 为 all 时,category 参数不支持 cost 和 free +## 中国银行 + + + ## 自如 diff --git a/lib/router.js b/lib/router.js index 4e9a4f37b4..1933252c4c 100755 --- a/lib/router.js +++ b/lib/router.js @@ -1347,6 +1347,9 @@ router.get('/paidai', require('./routes/paidai/index')); router.get('/paidai/bbs', require('./routes/paidai/bbs')); router.get('/paidai/news', require('./routes/paidai/news')); +// 中国银行 +router.get('/boc/whpj', require('./routes/boc/whpj')); + // 漫画db router.get('/manhuadb/comics/:id', require('./routes/manhuadb/comics')); diff --git a/lib/routes/boc/whpj.js b/lib/routes/boc/whpj.js new file mode 100644 index 0000000000..47522a5480 --- /dev/null +++ b/lib/routes/boc/whpj.js @@ -0,0 +1,45 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const link = 'http://www.boc.cn/sourcedb/whpj/'; + const response = await axios.get(link); + const $ = cheerio.load(response.data); + + const out = $('div.publish table tbody tr') + .slice(2) + .map(function() { + const name = $(this) + .find('td:nth-child(1)') + .text(); + const date = `${$(this) + .find('td:nth-child(7)') + .text()} ${$(this) + .find('td:nth-child(8)') + .text()}`; + const info = { + title: name, + description: `现汇买入价:${$(this) + .find('td:nth-child(2)') + .text()}
现钞买入价:${$(this) + .find('td:nth-child(3)') + .text()}
现汇卖出价:${$(this) + .find('td:nth-child(4)') + .text()}
现钞卖出价:${$(this) + .find('td:nth-child(5)') + .text()}
中行折算价:${$(this) + .find('td:nth-child(6)') + .text()}
`, + pubDate: new Date(date).toUTCString(), + guid: name + date, + }; + return info; + }) + .get(); + + ctx.state.data = { + title: '中国银行外汇牌价', + link: link, + item: out, + }; +};