Files
Toolbox/dev_test_scripts/debug/debug_dip_eval_sources4.js
yangxiangyuan 6a7a2b089a feat: 新增免费演出雷达工具与定投评估功能,优化周报提醒逻辑
1. 新增免费演出雷达工具:含秀动/猫眼/大麦平台抓取、本地代理鉴权配置
2. 新增建行定投评估模块:四大指数PE-TTM估值与定投档位建议
3. 新增推送告警白名单过滤功能,限制推送指定指数告警
4. 重构周报首页提醒逻辑,移至服务端处理并减少前端请求
5. 新增多套调试探针脚本与单元测试用例
2026-08-04 17:33:14 +08:00

52 lines
2.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 探针脚本(第四轮):确认中证官网 PE 口径(静态 vs 滚动 TTM)
* 中证500:index-perf 的 peg=26.53,蛋卷 pe=34.75,需确认 peg 是哪种口径
* 思路:
* 1. 中证官网每日 xls 文件(含 市盈率1/市盈率2 两个口径)
* 2. 中证官网其他含估值字段的接口
* 用法:node dev_test_scripts/debug/debug_dip_eval_sources4.js
*/
const axios = require('axios')
const UA = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36' }
;(async () => {
// 1. 中证官网 xls 每日文件(二进制,先看响应头与体积,再尝试文本化找市盈率列)
for (const code of ['000300', '000905']) {
try {
const url = `https://csi-web-dev.oss-cn-shanghai-finance-1-pub.aliyuncs.com/static/html/csindex/public/uploads/file/autofile/perf/${code}perf.xls`
const res = await axios.get(url, { timeout: 20000, responseType: 'arraybuffer', headers: UA, validateStatus: () => true })
const buf = Buffer.from(res.data)
console.log(`[xls ${code}] status=${res.status} bytes=${buf.length}`)
// xls 内文本片段(GBK),找“市盈率”附近的数字
let text = ''
try { text = require('iconv-lite').decode(buf, 'gb18030') } catch { text = buf.toString('latin1') }
const idx = text.indexOf('市盈率')
if (idx >= 0) {
console.log(`[xls ${code}] 表头附近: ${text.slice(Math.max(0, idx - 60), idx + 120).replace(/[^\x20-\x7E\u4e00-\u9fff,。.\-\r\n]/g, ' ')}`)
// 最后一行数据(最新日期行)
const lines = text.split(/\r?\n/).filter(l => /\d{4}\/\d{1,2}\/\d{1,2}|\d{8}/.test(l))
if (lines.length) console.log(`[xls ${code}] 最新数据行: ${lines[lines.length - 1].replace(/[^\x20-\x7E\u4e00-\u9fff,。.\-\r\n]/g, ' ').slice(0, 300)}`)
} else {
console.log(`[xls ${code}] 未找到“市盈率”字样,前200字节hex=${buf.slice(0, 100).toString('hex')}`)
}
} catch (e) {
console.log(`[xls ${code}] 异常: ${e.message}`)
}
}
// 2. 中证官网其他可能的估值接口
const candidates = [
'https://www.csindex.com.cn/csindex-home/perf/index-perf-detail?indexCode=000905',
'https://www.csindex.com.cn/csindex-home/index/valuation?indexCode=000905',
'https://www.csindex.com.cn/csindex-home/index/index-detail?indexCode=000905'
]
for (const url of candidates) {
try {
const res = await axios.get(url, { timeout: 15000, headers: { ...UA, 'Referer': 'https://www.csindex.com.cn/' }, validateStatus: () => true })
console.log(`[接口探测] ${url}\n status=${res.status} body=${JSON.stringify(res.data).slice(0, 400)}`)
} catch (e) {
console.log(`[接口探测] ${url} 异常: ${e.message}`)
}
}
})()