实时比分追踪器:随时获取足球比赛的最新结果

  • 发布于:2024-11-05 23:07:19
  • 来源:24直播网
实时比分追踪器

欢迎来到实时比分追踪器!在这里,您可以随时获取足球比赛的最新结果。

正在进行的比赛

比赛 比分 时间

最近完成的比赛

比赛 比分 时间
<script> // 获取实时比赛数据并填充表function getLiveMatches() {fetch('https://api.football-data.org/v2/matches', {headers: {'X-Auth-Token': 'YOUR_API_KEY'}}).then(response => response.json()).then(data => {const matches = data.matches;const tableBody = document.querySelector('table tbody');matches.forEach(match => {const row = document.createElement('tr');const matchCell = document.createElement('td');matchCell.textContent = `${match.homeTeam.name} vs ${match.awayTeam.name}`;const scoreCell = document.createElement('td');scoreCell.textContent = `${match.score.fullTime.homeTeam} - ${match.score.fullTime.awayTeam}`;const timeCell = document.createElement('td');timeCell.textContent = match.status ==='IN_PLAY' ? '进行中' : '已结束';row.appendChild(matchCell);row.appendChild(scoreCell);row.appendChild(timeCell);tableBody.appendChild(row);});}).catch(error => {console.error('Error fetching live matches:', error);});}// 获取最近完成的比赛数据并填充表function getFinishedMatches() {fetch('https://api.football-data.org/v2/matches', {headers: {'X-Auth-Token': 'YOUR_API_KEY'},query: {status: 'FINISHED'}}).then(response => response.json()).then(data => {const matches = data.matches;const tableBody = document.querySelector('table tbody');matches.forEach(match => {const row = document.createElement('tr');const matchCell = document.createElement('td');matchCell.textContent = `${match.homeTeam.name} vs ${match.awayTeam.name}`;const scoreCell = document.createElement('td');scoreCell.textContent = `${match.score.fullTime.homeTeam} - ${match.score.fullTime.awayTeam}`;const timeCell = document.createElement('td');timeCell.textContent = '已结束';row.appendChild(matchCell);row.appendChild(scoreCell);row.appendChild(timeCell);tableBody.appendChild(row);});}).catch(error => {console.error('Error fetching finished matches:', error);});}// 页面加载时获取实时比赛和最近完成的比赛数据window.addEventListener('load', () => {getLiveMatches();getFinishedMatches();}); </script>

相关阅读: 随时获取足球比赛的最新结果 实时比分追踪器

最新资讯