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, + }; +};