-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): Add ICBC; Fix BOC Date & trimming space (#13138)
* Add ICBC; Fix BOC Date & trimming space * use http instead of https * Update website/docs/routes/other.md * Update lib/routes/boc/whpj.js * refactor: migrate to v2 ---------
- Loading branch information
Showing
10 changed files
with
184 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/whpj/:format?': ['LogicJake', 'HenryQW'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'boc.cn': { | ||
_name: '中国银行', | ||
'.': [ | ||
{ | ||
title: '外汇牌价', | ||
docs: 'https://docs.rsshub.app/routes/others#zhong-guo-yin-hang', | ||
source: ['/sourcedb/whpj', '/'], | ||
target: '/boc/whpj', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/whpj/:format?', require('./whpj')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/whpj/:format?': ['leoleoasd'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'icbc.com.cn': { | ||
_name: '中国工商银行', | ||
'.': [ | ||
{ | ||
title: '外汇牌价', | ||
docs: 'https://docs.rsshub.app/other#zhong-guo-gong-shang-yin-hang', | ||
source: ['/column/1438058341489590354.html'], | ||
target: '/icbc/whpj', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/whpj/:format?', require('./whpj')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const got = require('@/utils/got'); | ||
|
||
module.exports = async (ctx) => { | ||
// yes, insecure | ||
// their openssl version isn't safe anyway (https://stackoverflow.com/questions/75763525/curl-35-error0a000152ssl-routinesunsafe-legacy-renegotiation-disabled) | ||
const { data } = await got('http://papi.icbc.com.cn/exchanges/ns/getLatest'); | ||
const format = ctx.params.format; | ||
|
||
ctx.state.data = { | ||
title: '中国工商银行外汇牌价', | ||
link: 'https://www.icbc.com.cn/column/1438058341489590354.html', | ||
item: data.data.map((item) => { | ||
const name = `${item.currencyCHName} ${item.currencyENName}`; | ||
|
||
const xhmr = `现汇买入价:${item.foreignBuy}`; | ||
|
||
const xcmr = `现钞买入价:${item.cashBuy}`; | ||
|
||
const xhmc = `现汇卖出价:${item.foreignSell}`; | ||
|
||
const xcmc = `现钞卖出价:${item.cashSell}`; | ||
|
||
const zs = `参考价:${item.reference}`; | ||
|
||
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}`; | ||
} | ||
}; | ||
return { | ||
title: formatTitle(), | ||
pubDate: new Date(`${item.publishDate} ${item.publishTime}`), | ||
description: content.replace(/\s/g, '<br>'), | ||
guid: `${name} ${item.publishDate} ${item.publishTime}`, | ||
}; | ||
}), | ||
}; | ||
}; |
Oops, something went wrong.