diff --git a/docs/other.md b/docs/other.md index 68f0ff7542..5f40344986 100644 --- a/docs/other.md +++ b/docs/other.md @@ -791,8 +791,7 @@ type 为 all 时,category 参数不支持 cost 和 free ### 首页 - - + ## 移动支付网 @@ -816,7 +815,13 @@ type 为 all 时,category 参数不支持 cost 和 free ### 中国银行外汇牌价 - + + +| 短格式 | 中行折算价 | 现汇买卖 | 现钞买卖 | 现汇买入 | 现汇卖出 | 现钞买入 | 现钞卖出 | +| ------ | ---------- | -------- | -------- | -------- | -------- | -------- | -------- | +| short | zs | xh | xc | xhmr | xhmc | xcmr | xcmc | + + ## 自如 diff --git a/lib/router.js b/lib/router.js index 3c1b8169fc..f67b2ae6a0 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1282,7 +1282,7 @@ router.get('/paidai/bbs', require('./routes/paidai/bbs')); router.get('/paidai/news', require('./routes/paidai/news')); // 中国银行 -router.get('/boc/whpj', require('./routes/boc/whpj')); +router.get('/boc/whpj/:format?', 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 index 9691c0a1c4..bca1dc2516 100644 --- a/lib/routes/boc/whpj.js +++ b/lib/routes/boc/whpj.js @@ -6,6 +6,8 @@ module.exports = async (ctx) => { const response = await axios.get(link); const $ = cheerio.load(response.data); + const format = ctx.params.format; + const out = $('div.publish table tbody tr') .slice(2) .map(function() { @@ -17,19 +19,54 @@ module.exports = async (ctx) => { .text()} ${$(this) .find('td:nth-child(8)') .text()}`; - const content = `现汇买入价:${$(this) + + const xhmr = `现汇买入价:${$(this) .find('td:nth-child(2)') - .text()} 现钞买入价:${$(this) + .text()}`; + + const xcmr = `现钞买入价:${$(this) .find('td:nth-child(3)') - .text()} 现汇卖出价:${$(this) + .text()}`; + + const xhmc = `现汇卖出价:${$(this) .find('td:nth-child(4)') - .text()} 现钞卖出价:${$(this) + .text()}`; + + const xcmc = `现钞卖出价:${$(this) .find('td:nth-child(5)') - .text()} 中行折算价:${$(this) + .text()}`; + + const zs = `中行折算价:${$(this) .find('td:nth-child(6)') .text()}`; + + const content = `${xhmr} ${xcmr} ${xhmc} ${xcmc} ${zs}`; + + const formatTitle = () => { + switch (format) { + case 'short': + return name; + case 'xh': + return `${name} ${xhmr} ${xhmc}`; + case 'xc': + return `${name} ${xcmr} ${xcmc}`; + case 'zs': + return `${name} ${zs}`; + case 'xhmr': + return `${name} ${xhmr}`; + case 'xhmc': + return `${name} ${xhmc}`; + case 'xcmr': + return `${name} ${xcmr}`; + case 'xcmc': + return `${name} ${xcmc}`; + default: + return name + content; + } + }; + const info = { - title: name + ' ' + content, + title: formatTitle(), description: content.replace(/\s/g, '
'), pubDate: new Date(date).toUTCString(), guid: name + date,