篮球联赛数据api示例

简介: 篮球联赛数据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}
相关文章
|
1月前
|
数据采集 JSON Java
揭秘阿里巴巴:如何通过API实时捕获中国市场商品数据
阿里巴巴提供了丰富的API接口,使得第三方开发者可以实时捕获中国市场商品数据。以下是一些关键步骤和要点,帮助你揭秘如何通过阿里巴巴的API实现这一目标:
|
1月前
|
JSON Java API
教你如何使用API接口获取数据
随着互联网技术的发展和应用的普及,越来越多的系统和应用提供API接口供其他系统和应用进行数据交互。通过API接口,我们可以获取到各种各样的数据,例如天气预报、股票行情、新闻摘要等等。本文将介绍如何使用API接口获取数据,并附有示例代码。
|
9天前
|
JSON 监控 API
在API接口对接中关键示例问题(1)
在API接口对接中,有几个关键的问题需要注意,以确保接口的稳定性、安全性和易用性。以下是这些问题及部分示例代码的简要概述
|
25天前
|
供应链 搜索推荐 BI
深入了解淘宝原数据:获取API接口及其使用场景
在当今数字化的时代,对于电商行业来说,数据具有极大的价值。淘宝作为中国最大的综合电商平台,拥有庞大的商品信息和用户数据。对于开发者和企业来说,淘宝原数据的获取和分析是实现个性化服务和精准营销的基础。本文将介绍如何通过API接口获取淘宝原数据,以及数据的使用场景。
|
1月前
|
Java API PHP
获取1688商品详情API:步骤与代码示例
在电子商务领域,阿里巴巴的1688平台是一个广受商家和开发者欢迎的批发交易市场。若您是一名开发者,希望建立自己的应用程序或网站来获取并展示1688上的商品信息,您可能需要使用到1688提供的API接口。以下是获取1688商品详情API的详细步骤说明。
|
1月前
|
数据采集 API 开发者
调用API接口获取小红书笔记详情数据(小红书怎么推广)
小红书平台对于其API的使用有严格的规定和限制,并且并非所有的功能和数据都通过公开API提供。关于获取小红书笔记详情的API,以下是一些建议和指导:
|
1月前
|
存储 分布式计算 API
adb spark的lakehouse api访问内表数据,还支持算子下推吗
【2月更文挑战第21天】adb spark的lakehouse api访问内表数据,还支持算子下推吗
107 2
|
1月前
|
Java API
Java 日期和时间 API:实用技巧与示例 - 轻松处理日期和时间
简介 Scanner 类用于获取用户输入,它位于 java.util 包中。 使用 Scanner 类 要使用 Scanner 类,请执行以下步骤: 导入 java.util.Scanner 包。 创建一个 Scanner 对象,并将其初始化为 System.in。 使用 Scanner 对象的方法读取用户输入。
52 1
|
1月前
|
JSON JavaScript 前端开发
使用API接口获取商品数据:从入门到实践
随着电子商务的飞速发展,许多电商平台提供了API接口,允许开发者获取商品数据,以创建各种创新的应用。本文将详细介绍如何使用API接口获取商品数据,并通过代码示例进行演示。
|
1月前
|
监控 供应链 搜索推荐
革新商务数据体验:引领市场的API商品数据接口
在当今商业环境中,革新商务数据体验对于维持竞争优势至关重要。API商品数据接口在这一转型过程中扮演了核心角色,它不仅为企业提供了实时且全面的数据访问能力,而且还极大地增强了数据的可操作性和决策支持功能。以下是API商品数据接口如何细致地改善商务数据管理:

热门文章

最新文章