足球数据API接口 - 【指数接口1】API调用示例代码
继续分享使用接口调用的示例代码,这次是 【即时指数接口1】
package com.huaying.demo.football;import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;/*** @API: 14.即时指数接口*/
public class FootballOdds100 {public static void main(String[] args) {try {String content = getContent();JAXBContext jaxbContext = JAXBContext.newInstance(MatchList.class);Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();MatchList matchList = (MatchList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes()));matchList.getMatchList().forEach(item -> System.out.println(item));} catch (Throwable t) {t.printStackTrace();}}/*** 获取API返回内容** Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容*/private static String getContent() {try {StringBuilder builder = new StringBuilder();List<String> lines = Files.readAllLines(Paths.get("./src/main/resources/FootballBet100.xml"), StandardCharsets.UTF_8);lines.forEach(line -> builder.append(line));return builder.toString();} catch (Throwable t) {t.printStackTrace();return "";}}@XmlRootElement(name = "c")public static class MatchList {private List<Match> matchList;@XmlElement(name = "h")public List<Match> getMatchList() {return matchList;}public void setMatchList(List<Match> matchList) {this.matchList = matchList;}}public static class Match{@XmlElement(name = "id")private String matchId;@XmlElement(name = "time")private String matchTime;@XmlElement(name = "league")private String leagueName;@XmlElement(name = "home")private String homeTeamName;@XmlElement(name = "away")private String awayTeamName;@XmlElement(name = "odds")private List<Odds> oddsList;@Overridepublic String toString() {return "Match{" +"matchId='" + matchId + '\'' +", matchTime='" + matchTime + '\'' +", leagueName='" + leagueName + '\'' +", homeTeamName='" + homeTeamName + '\'' +", awayTeamName='" + awayTeamName + '\'' +", oddsList=" + oddsList +'}';}public String getMatchId() {return matchId;}public String getMatchTime() {return matchTime;}public String getLeagueName() {return leagueName;}public String getHomeTeamName() {return homeTeamName;}public String getAwayTeamName() {return awayTeamName;}public List<Odds> getOddsList() {return oddsList;}}private static class Odds{@XmlElement(name = "o")private String item;@Overridepublic String toString() {return "Odds{" +"item='" + item + '\'' +'}';}public String getItem() {return item;}}
}
API 返回数据如下:
Match{matchId='1755160', matchTime='2019/7/22 17:30:00', leagueName='INT CF,球會友誼,球会友谊', homeTeamName='Caldas,卡爾達斯,卡尔达斯', awayTeamName='Al-Nasr(KSA),艾納斯,艾纳斯', oddsList=[Odds{item='null'}]}
Match{matchId='1755377', matchTime='2019/7/22 17:45:00', leagueName='CFL,加爾聯,加尔联', homeTeamName='WB Police SC,WB警察SC,WB警察SC', awayTeamName='CFC,CFC,CFC', oddsList=[Odds{item='281,Bet 365,1.8,3,4.5,,,,2019/7/22 15:28:00,bet 365(英国)'}]}
Match{matchId='1700121', matchTime='2019/7/22 18:00:00', leagueName='KOR WD1,韓女聯,韩女联', homeTeamName='Boeun Sangmu (w),報恩尚武女足,报恩尚武女足', awayTeamName='Gyeongju FC W,慶州FC女足,庆州FC女足', oddsList=[Odds{item='1047,1xBet,4.56,4.1,1.63,4.58,4.28,1.6,2019/7/22 14:44:00,1xBet'}]}
Match{matchId='1700123', matchTime='2019/7/22 18:00:00', leagueName='KOR WD1,韓女聯,韩女联', homeTeamName='Hyundai Steel Red Angels (w),現代制鐵女足,现代制铁女足', awayTeamName='KSPO FC (w),華川KSPO女足,华川KSPO女足', oddsList=[Odds{item='1231,LeonBets,1.51,4.45,5.15,1.41,4.8,6.25,2019/7/22 17:36:00,LeonBets'}]}
足球数据API接口 - 【指数接口1】API调用示例代码相关推荐
- dota2 java_电竞Dota2数据API接口 - 【战队列表】调用示例代码
分享调用飞鲸电竞数据DOTA2的数据接口,在线接口文档,需注册 import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.annota ...
- 【破晓字节】电竞API接口调用示例代码-即时指数
[破晓字节]电竞API接口调用示例代码-即时指数 使用破晓字节的电竞指数数据快一年了,分享使用指数接口的示例代码.游戏包括英雄联盟.王者荣耀.CS:GO.DOTA2.PUBG.穿越火线等等,联赛覆盖和 ...
- 电竞英雄联盟数据API接口 - 【比赛列表】API调用示例代码
电竞英雄联盟数据API接口 - [比赛列表]API调用示例代码 分享使用 野子科技数据 https://www.xxe.io/ 接口调用的示例代码,今天接的是英雄联盟的[比赛列表]接口,跟之前不同的是 ...
- 竞彩足球混合过关赔率API调用示例代码
<?php // +---------------------------------------------------------------------- // | 竞彩足球混合过关赔率A ...
- 竞彩足球混合过关赔率API调用示例代码2020版
$user = 'smmz'; $secret = '2e54c7eae2c5a6c01'; //竞彩足球混合过关数据 // +------------------------------------ ...
- java实时汇率的接口_eoLinker-API_Shop_汇率查询_API接口_Java调用示例代码
eoLinker-API Shop 汇率查询 Java调用示例代码 汇率查询 提供汇率转换.单个货币对应的热门货币汇率行情,包括人民币.美元.欧元.英镑等100多种货币的实时汇率查询. 该产品拥有以下 ...
- java 二十四节气,eoLinker-API_Shop_二十四节气查询_API接口_Java调用示例代码
eoLinker-API Shop 二十四节气查询 Java调用示例代码 二十四节气查询 二十四节气的时间.由来.习俗以及养生 该产品拥有以下APIs: 1.查询二十四节气 2.查询节气详情 注意,该 ...
- 足球数据API接口 - 【即时指数2】API调用示例代码
分享使用接口调用的示例代码,这次的解析和以前不同,是[即时指数2] import java.nio.charset.StandardCharsets; import java.nio.file.Fil ...
- 足球数据API接口 - 【球员资料】API调用示例代码
分享下近期使用[球员资料]接口调用的示例代码. 近期感觉并没有遇到什么难点,很易用,另外作为足球比分数据API接口还是挺全面的 import javax.xml.bind.JAXBContext; i ...
最新文章
- python目录操作shutil
- JMS分布式应用程序异步消息解决方案EhCache 高速缓存同步问题
- Spring Boot 系列(五)web开发-Thymeleaf、FreeMarker模板引擎
- MySQL流程控制的使用
- Jupyter中打印所有结果的解决办法
- c# 调用c库dll ,char*转string的解决办法
- 修正CS2.0中的日历头显示错误
- MySQL各个版本区别
- postfix邮件服务器
- wpf开源ui引用步骤_完善开源产品策略的6个步骤
- 【AI】统计学和机器学习到底有什么区别?
- linux 2.6内核进程调度,Linux2.6内核进程调度系列--scheduler_tick()函数2.更新实时进程的时间片,...
- GIS之旅——大学本科总结
- 安装LoadRunner 11时弹窗提示Micosoft Visual C++ 2005 SP1 可再发行组件包(X86):'命令行选项语法错误。键入命令 / ? 可获得帮助信息'。
- Android PreferenceScreen
- 漫谈敏捷方法中的信任
- Windows安全更新出现0x800f081f错误解决方案
- 马克飞象markdown用法
- 小程序开发API之监听加速计wx.startAccelerometer
- QGIS添加常用的数据源