// BSE 股票代码获取脚本 // 数据源: Alice Blue Broker CSV (每日更新, 免费, 无需注册) const url = 'https://v2api.aliceblueonline.com/restpy/static/contract_master/BSE.csv'; const res = await fetch(url); const csv = await res.text(); const lines = csv.split('\n').filter(Boolean); const stocks = []; for (let i = 1; i < lines.length; i++) { const cols = lines[i].split(','); if (cols.length < 6) continue; const symbol = cols[2].trim(); // Symbol (ticker) const token = cols[3].trim(); // Token (BSE security code) const type = cols[4].trim(); // Instrument type if (type !== 'E') continue; // Equity only stocks.push({ c: token, n: symbol }); } // 输出格式 process.stdout.write(`var s = new Array();\n`); for (let i = 0; i < stocks.length; i++) { process.stdout.write(`s[${i}] = { c: "${stocks[i].c}", n: "${stocks[i].n}" };\n`); } console.error(`\n总计: ${stocks.length} 只 BSE 股票`);