koishi-plugin-bns-rate 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -33,15 +33,15 @@ async function fetchRate(ctx, url) {
|
|
|
33
33
|
throw new Error('无法解析页面汇率数据,页面结构可能已变更')
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// match[0] =
|
|
37
|
-
const forward = parseFloat(forwardMatches[
|
|
36
|
+
// match[0] = 平台极速收货回收价(跳过), match[1] = 比例最佳排序第一条=最低卖家挂单价
|
|
37
|
+
const forward = parseFloat(forwardMatches[1][1])
|
|
38
38
|
|
|
39
39
|
const reverseMatches = [...html.matchAll(REVERSE_RE)]
|
|
40
40
|
if (reverseMatches.length < 2) {
|
|
41
41
|
throw new Error('无法解析页面反向汇率数据')
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const reverse = parseFloat(reverseMatches[
|
|
44
|
+
const reverse = parseFloat(reverseMatches[1][1])
|
|
45
45
|
|
|
46
46
|
if (forward < 100 || forward > 200 || reverse < 0.001 || reverse > 0.02) {
|
|
47
47
|
throw new Error(`解析的汇率超出合理范围: forward=${forward}, reverse=${reverse}`)
|