篮球联赛数据api示例
分享之前调用过的体育数据api,可注册使用下篮球联赛数据,在线文档
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: 4.联赛、赛事资料 * @Website: https://www.feijing88.com */ public class BasketballLeagueInfo { public static void main(String[] args) { try { String content = getContent(); JAXBContext jaxbContext = JAXBContext.newInstance(LeagueList.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); LeagueList list = (LeagueList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes())); list.getLeagueList().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/BasketballLeagueInfo.xml"), StandardCharsets.UTF_8); lines.forEach(builder::append); return builder.toString(); } catch (Throwable t) { t.printStackTrace(); return ""; } } @XmlRootElement(name = "list") public static class LeagueList { @XmlElement(name = "match") private List<League> leagueList; public List<League> getLeagueList() { return leagueList; } } public static class League { @XmlElement(name = "id") private String id; @XmlElement(name = "short") private String nameShort; @XmlElement(name = "gb") private String nameGb; @XmlElement(name = "big") private String nameBig; @XmlElement(name = "en") private String nameEn; @XmlElement(name = "type") private int type; @XmlElement(name = "Curr_matchSeason") private String currentSeason; @XmlElement(name = "countryID") private String countryId; @XmlElement(name = "country") private String countryName; @XmlElement(name = "curr_year") private int currentYear; @XmlElement(name = "curr_month") private int currentMonth; @XmlElement(name = "sclass_kind") private int kind; @Override public String toString() { return "League{" + "id='" + id + '\'' + ", nameShort='" + nameShort + '\'' + ", nameGb='" + nameGb + '\'' + ", nameBig='" + nameBig + '\'' + ", nameEn='" + nameEn + '\'' + ", type=" + type + ", currentSeason='" + currentSeason + '\'' + ", countryId='" + countryId + '\'' + ", countryName='" + countryName + '\'' + ", currentYear=" + currentYear + ", currentMonth=" + currentMonth + ", kind=" + kind + '}'; } } }
API 返回数据如下(部分):
League{id='2', nameShort='WNBA', nameGb='美国女子职业篮球联赛', nameBig='美國女子職業籃球聯賽', nameEn='Women’s National Basketball Association', type=4, currentSeason='19', countryId='1', countryName='美国', currentYear=2011, currentMonth=9, kind=1} League{id='3', nameShort='斯坦杯', nameGb='斯坦科维奇洲际冠军杯', nameBig='斯坦科域治洲際冠軍盃', nameEn='Stank Vic Basketball Champions LeagueChampions Cup', type=4, currentSeason='18', countryId='20', countryName='国际赛事', currentYear=2011, currentMonth=8, kind=2} League{id='5', nameShort='CBA', nameGb='中国男子篮球联赛', nameBig='中國男子籃球聯賽', nameEn='Chinese Basketball Association', type=4, currentSeason='18-19', countryId='2', countryName='中国', currentYear=2011, currentMonth=11, kind=1} League{id='7', nameShort='Euro', nameGb='欧洲篮球冠军联赛', nameBig='歐洲籃球冠軍聯賽', nameEn='EURO', type=4, currentSeason='19-20', countryId='16', countryName='欧洲赛事', currentYear=2011, currentMonth=10, kind=2} League{id='8', nameShort='NCAA', nameGb='美国大学男子篮球联赛', nameBig='美國大學男子籃球聯賽', nameEn='National Committee Association America', type=2, currentSeason='18-19', countryId='1', countryName='美国', currentYear=2009, currentMonth=11, kind=1} League{id='9', nameShort='女南锦U17', nameGb='南美洲女子篮球锦标赛U17', nameBig='女南錦U17', nameEn='FIBA Sudamericano Femenino U17', type=4, currentSeason='17', countryId='18', countryName='美洲赛事', currentYear=2011, currentMonth=6, kind=2} League{id='10', nameShort='篮世杯', nameGb='篮球世界杯', nameBig='籃球世界盃', nameEn='FIBA Basketball World Cup', type=4, currentSeason='19', countryId='20', countryName='国际赛事', currentYear=2010, currentMonth=8, kind=2} League{id='13', nameShort='世女俱', nameGb='世女俱', nameBig='世女俱', nameEn='The world women Club', type=4, currentSeason='17', countryId='20', countryName='国际赛事', currentYear=2007, currentMonth=10, kind=2}
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
足球即时比分api示例代码
这里简单介绍下之前参与项目过程调取的足球比分api示例代码,在线文档查看 val elements = fetchElementList("http://interface.win007.com/zq/today.aspx", "match") return elements.map { val leagueMix = MixString(it["league"]) val homeTeamMix = MixString(it["home"]) val awayTeamMix = MixString(it["away"]) FootballMatch( matchId = it["ID"], level = it["level"].toIntOr(), leagueId = it["leagueID"], leagueType = it["kind"].toIntOr(1), leagueName = leagueMix[2], matchTime = it["time"].parseSlashTimestamp(), startTime = it["time2"].parseSlas...
- 下一篇
Beetl 3.0.19 版本发布,Java 模板引擎
本次发布增加了includeFragment扩展,以及整合了Beetl爱好者提供的新扩展 StringUtil 增加了extendString系列辅助函数,用于格式化字符串 增加includeFragment扩展,可以允许包含模板的一部分内容,例子如下 includeFragment("/all.html","frag1"){} 或者 <#html:includeFragment file="/all.html" fragment="frag1" arg1="" arg2=""/> all.html内容如下,#fragment用于表示模板片段 <% #fragment frag1:{ %> 内容片段一 <%}%> <% #fragment frag2:{ %> 内容片段二 <%}%> maven <dependency> <groupId>com.ibeetl</groupId> <artifactId>beetl</art...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS7,CentOS8安装Elasticsearch6.8.6
- CentOS6,CentOS7官方镜像安装Oracle11G
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- CentOS8编译安装MySQL8.0.19
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- Windows10,CentOS7,CentOS8安装Nodejs环境
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7