6a7a2b089a
1. 新增免费演出雷达工具:含秀动/猫眼/大麦平台抓取、本地代理鉴权配置 2. 新增建行定投评估模块:四大指数PE-TTM估值与定投档位建议 3. 新增推送告警白名单过滤功能,限制推送指定指数告警 4. 重构周报首页提醒逻辑,移至服务端处理并减少前端请求 5. 新增多套调试探针脚本与单元测试用例
28 lines
1.3 KiB
JavaScript
28 lines
1.3 KiB
JavaScript
// 调试:验证 free_show_local_agent.js 的 extractPrice 价格提取逻辑
|
|
// 用法:node dev_test_scripts/debug/debug_price_extract.js
|
|
'use strict'
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const src = fs.readFileSync(path.join(__dirname, '..', '..', 'public', 'tools', 'free_show', 'free_show_local_agent.js'), 'utf-8')
|
|
const m = src.match(/function extractPrice[\s\S]*?\n}/)
|
|
if (!m) { console.log('FAIL: 未找到 extractPrice'); process.exit(1) }
|
|
const extractPrice = new Function('return ' + m[0])()
|
|
|
|
const cases = [
|
|
['<div class="itemprice">130-2620<span>元</span></div>', 130, '130-2620元'],
|
|
['... 380.0元 起 ...', 380, '380.0元'],
|
|
['¥130起', 130, '¥130'],
|
|
['2026.08.03-08.30 上海', null, null], // 日期不应误判为价格
|
|
['价格待定', null, null]
|
|
]
|
|
let fail = 0
|
|
for (const [input, wantPrice, wantText] of cases) {
|
|
const got = extractPrice(input)
|
|
const okPrice = wantPrice === null ? got === null : got && got.price === wantPrice
|
|
const okText = wantText === null ? got === null : got && got.priceText === wantText
|
|
if (okPrice && okText) console.log(`PASS: ${JSON.stringify(input)} => ${JSON.stringify(got)}`)
|
|
else { fail++; console.log(`FAIL: ${JSON.stringify(input)} => ${JSON.stringify(got)} (want ${wantPrice}/${wantText})`) }
|
|
}
|
|
process.exit(fail ? 1 : 0)
|