篮球即时比分api接口调用示例代码
分享篮球即时比分api接口调用的示例代码,可查看在线调用文档,需注册下
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; import java.util.stream.Collectors; /** * @API: 2.即时变化的比分数据 * @Website: https://www.feijing88.com */ public class BasketballChange { public static void main(String[] args) { try { String content = getContent(); JAXBContext jaxbContext = JAXBContext.newInstance(ChangeList.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); ChangeList list = (ChangeList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes())); list.getChangeList().forEach(System.out::println); } catch (Throwable t) { t.printStackTrace(); } } /** * 获取API返回内容 * <p> * Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容 */ private static String getContent() { try { StringBuilder builder = new StringBuilder(); List<String> lines = Files.readAllLines(Paths.get("./src/main/resources/BasketballChange.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 ChangeList { @XmlElement(name = "h") private List<String> itemList; public List<Change> getChangeList() { return itemList.stream().map(s -> { Change change = new Change(); change.parse(s); return change; }).collect(Collectors.toList()); } } public static class Change { private String matchId; private int matchStatus; private String remainTime; private int homeScore; private int homeScoreFirst; private int homeScoreSecond; private int homeScoreThird; private int homeScoreFourth; private int homeScoreFirstOT; private int homeScoreSecondOT; private int homeScoreThirdOT; private int awayScore; private int awayScoreFirst; private int awayScoreSecond; private int awayScoreThird; private int awayScoreFourth; private int awayScoreFirstOT; private int awayScoreSecondOT; private int awayScoreThirdOT; public void parse(String data) { String[] values = data.split("\\^"); matchId = values[0]; matchStatus = parseInt(values[1]); remainTime = values[2]; homeScore = parseInt(values[3]); homeScoreFirst = parseInt(values[5]); homeScoreSecond = parseInt(values[7]); homeScoreThird = parseInt(values[9]); homeScoreFourth = parseInt(values[11]); homeScoreFirstOT = parseInt(values[16]); homeScoreSecondOT = parseInt(values[18]); homeScoreThirdOT = parseInt(values[20]); awayScore = parseInt(values[4]); awayScoreFirst = parseInt(values[6]); awayScoreSecond = parseInt(values[8]); awayScoreThird = parseInt(values[10]); awayScoreFourth = parseInt(values[12]); awayScoreFirstOT = parseInt(values[17]); awayScoreSecondOT = parseInt(values[19]); awayScoreThirdOT = parseInt(values[21]); } private int parseInt(String data) { return data == null || data.isEmpty() ? 0 : Integer.valueOf(data); } @Override public String toString() { return "Change{" + "matchId='" + matchId + '\'' + ", matchStatus=" + matchStatus + ", remainTime='" + remainTime + '\'' + ", homeScore=" + homeScore + ", homeScoreFirst=" + homeScoreFirst + ", homeScoreSecond=" + homeScoreSecond + ", homeScoreThird=" + homeScoreThird + ", homeScoreFourth=" + homeScoreFourth + ", homeScoreFirstOT=" + homeScoreFirstOT + ", homeScoreSecondOT=" + homeScoreSecondOT + ", homeScoreThirdOT=" + homeScoreThirdOT + ", awayScore=" + awayScore + ", awayScoreFirst=" + awayScoreFirst + ", awayScoreSecond=" + awayScoreSecond + ", awayScoreThird=" + awayScoreThird + ", awayScoreFourth=" + awayScoreFourth + ", awayScoreFirstOT=" + awayScoreFirstOT + ", awayScoreSecondOT=" + awayScoreSecondOT + ", awayScoreThirdOT=" + awayScoreThirdOT + '}'; } } }
API 返回数据如下(部分):
Change{matchId='358761', matchStatus=2, remainTime='06:50', homeScore=20, homeScoreFirst=14, homeScoreSecond=6, homeScoreThird=0, homeScoreFourth=0, homeScoreFirstOT=0, homeScoreSecondOT=0, homeScoreThirdOT=0, awayScore=44, awayScoreFirst=31, awayScoreSecond=13, awayScoreThird=0, awayScoreFourth=0, awayScoreFirstOT=0, awayScoreSecondOT=0, awayScoreThirdOT=0}
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
电竞CSGO数据API接口 - 【联赛列表】API调用示例代码
电竞CSGO的【联赛列表】接口,在线文档查阅,需注册下 import com.alibaba.fastjson.annotation.JSONField; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; /** * @API: 联赛列表 * @Website: https://www.feijing88.com */ public class CsgoLeague { public static void main(String[] args) { try { String content = getContent(); Respond rsp = JSON.parseObject(content, Respond.class); System.out.println(rsp.code); System.out.println(rsp.message); rsp.getLeagueList()....
- 下一篇
什么是HDFS?算了,告诉你也不懂。
前言 只有光头才能变强。 文本已收录至我的GitHub精选文章,欢迎Star:https://github.com/ZhongFuCheng3y/3y 上一篇已经讲解了「大数据入门」的相关基础概念和知识了,这篇我们来学学HDFS。如果文章有错误的地方,不妨在评论区友善指出~ 一、HDFS介绍 上篇文章已经讲到了,随着数据量越来越大,在一台机器上已经无法存储所有的数据了,那我们会将这些数据分配到不同的机器来进行存储,但是这就带来一个问题:不方便管理和维护 所以,我们就希望有一个系统可以将这些分布在不同操作服务器上的数据进行统一管理,这就有了分布式文件系统 HDFS是分布式文件系统的其中一种(目前用得最广泛的一种) 在使用HDFS的时候是非常简单的:虽然HDFS是将文件存储到不同的机器上,但是我去使用的时候是把这些文件当做是存储在一台机器的方式去使用(背后却是多台机器在执行): 好比:我调用了一个RPC接口,我给他参数,他返回一个response给我。RPC接口做了什么事其实我都不知道的(可能这个RPC接口又调了其他的RPC接口)-----屏蔽掉实现细节,对用户友好 明确一下:HDFS就是...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS7设置SWAP分区,小内存服务器的救世主
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- Linux系统CentOS6、CentOS7手动修改IP地址
- CentOS7,8上快速安装Gitea,搭建Git服务器
- CentOS8安装MyCat,轻松搞定数据库的读写分离、垂直分库、水平分库
- SpringBoot2整合Redis,开启缓存,提高访问速度
- MySQL8.0.19开启GTID主从同步CentOS8
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- Docker使用Oracle官方镜像安装(12C,18C,19C)