最新股价
历史股价
(function () {const currentPrice = document.getElementById('current-price');const historicalPrices = document.getElementById('historical-prices');// 获取当前股价fetch('https://hq.sinajs.cn/list=sh600999').then(res => res.text()).then(data => {const stockInfo = data.split(',');currentPrice.innerText = `最新价:${stockInfo[3]}元`;}).catch(error => {currentPrice.innerText = '无法获取当前股价';console.error('获取当前股价失败:', error);});// 获取历史股价const now = new Date();const startDate = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate() - 1);const endDate = new Date();const params = {symbol: 'sh600999',startDate: startDate.toLocaleDateString('zh-CN').replace(/\//g, '-'),endDate: endDate.toLocaleDateString('zh-CN').replace(/\//g, '-')};fetch(``, {method: 'GET',headers: {'Content-Type': 'application/x-www-form-urlencoded'},params}).then(res => res.text()).then(data => {const startIndex = data.indexOf('[');const endIndex = data.lastIndexOf(']');const json = JSON.parse(data.substring(startIndex, endIndex + 1));const { result: stockData } = json.pageHelp.data;stockData.forEach(stock => {const tr = document.createElement('tr');const date = document.createElement('td');date.innerText = stock[0];const open = document.createElement('td');open.innerText = stock[1];const high = document.createElement('td');high.innerText = stock[2];const low = document.createElement('td');low.innerText = stock[3];const close = document.createElement('td');close.innerText = stock[4];tr.appendChild(date);tr.appendChild(open);tr.appendChild(high);tr.appendChild(low);tr.appendChild(close);historicalPrices.appendChild(tr);});}).catch(error => {console.error('获取历史股价失败:', error);});})();
标签: 赤峰黄金股票价格多少
版权声明:除非特别标注,否则均为本站转摘于网络,转载时请以链接形式注明文章出处。