import { NextResponse } from 'next/server'; async function fetchGZ(code) { const url = `https://fundgz.1234567.com.cn/js/${code}.js`; const res = await fetch(url, { cache: 'no-store' }); if (!res.ok) throw new Error('估值接口异常'); const text = await res.text(); const m = text.match(/jsonpgz\((.*)\);/); if (!m) throw new Error('估值数据解析失败'); const json = JSON.parse(m[1]); const gszzlNum = Number(json.gszzl); return { code: json.fundcode, name: json.name, dwjz: json.dwjz, gsz: json.gsz, gztime: json.gztime, gszzl: Number.isFinite(gszzlNum) ? gszzlNum : json.gszzl }; } function stripHtml(s) { return s.replace(/<[^>]*>/g, '').replace(/\s+/g, ' ').trim(); } function parseHoldings(html) { const list = []; const tableMatch = html.match(/