篮球联赛数据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}
相关文章
|
25天前
|
JSON API 数据格式
淘宝/天猫图片搜索API接口,json返回数据。
淘宝/天猫平台虽未开放直接的图片搜索API,但可通过阿里妈妈淘宝联盟或天猫开放平台接口实现类似功能。本文提供基于淘宝联盟的图片关联商品搜索Curl示例及JSON响应说明,适用于已获权限的开发者。如需更高精度搜索,可选用阿里云视觉智能API。
|
23天前
|
JSON API 数据安全/隐私保护
深度分析淘宝卖家订单详情API接口,用json返回数据
淘宝卖家订单详情API(taobao.trade.fullinfo.get)是淘宝开放平台提供的重要接口,用于获取单个订单的完整信息,包括订单状态、买家信息、商品明细、支付与物流信息等,支撑订单管理、ERP对接及售后处理。需通过appkey、appsecret和session认证,并遵守调用频率与数据权限限制。本文详解其使用方法并附Python调用示例。
|
23天前
|
缓存 API 网络架构
淘宝item_search_similar - 搜索相似的商品API接口,用python返回数据
淘宝联盟开放平台中,可通过“物料优选接口”(taobao.tbk.dg.optimus.material)实现“搜索相似商品”功能。该接口支持根据商品 ID 获取相似推荐商品,并返回商品信息、价格、优惠等数据,适用于商品推荐、比价等场景。本文提供基于 Python 的实现示例,包含接口调用、数据解析及结果展示。使用时需配置淘宝联盟的 appkey、appsecret 和 adzone_id,并注意接口调用频率限制和使用规范。
|
25天前
|
JSON API 开发者
淘宝店铺的所有商品API接口,Curl返回数据
淘宝平台未开放获取全店商品的公共API,开发者可通过阿里妈妈的淘宝联盟API获取参与推广的商品。需成为联盟开发者、创建应用,并通过adzone_id关联店铺。使用taobao.tbk.shop.get和taobao.tbk.item.info.get接口,可获取商品列表及详情,但需注意签名生成、调用频率限制及合规要求。未参与推广的商品无法通过该方式获取。
|
26天前
|
人工智能 JSON 算法
抖音电商 API 赋能,抖音平台达人合作数据精准对接
抖音电商API为品牌与达人合作提供精准数据对接,提升匹配效率与营销精准度,助力电商生态智能化升级。
112 1
|
27天前
|
API 开发工具 开发者
客流类API实测:门店到访客群画像数据
本文介绍了一个实用的API——“门店到访客群画像分布”,适用于线下实体门店进行客群画像分析。该API支持多种画像维度,如性别、年龄、职业、消费偏好等,帮助商家深入了解顾客特征,提升运营效率。文章详细说明了API的参数配置、响应数据、接入流程,并附有Python调用示例,便于开发者快速集成。适合零售、餐饮等行业从业者使用。
客流类API实测:门店到访客群画像数据
|
25天前
|
JSON 数据挖掘 API
淘宝详情API接口与高级详情API接口用json返回数据区别
淘宝“商品详情API”与“高级商品API”主要区别在于数据深度、字段丰富度及适用场景。前者适用于轻量级导购展示,后者支持详情页展示与深度分析,需根据业务需求选择使用。
|
28天前
|
监控 算法 API
电商API接口对接实录:淘宝优惠券接口对接处理促销监控系统
在电商开发中,淘宝详情页的“券后价计算”是极易出错的环节。本文作者结合实战经验,分享了因忽略满减券门槛、有效期、适用范围等导致的踩坑经历,并提供了完整的解决方案,包括淘宝API签名生成、券后价计算逻辑、常见坑点及优化建议,助力开发者精准实现券后价功能,避免业务损失。
|
1月前
|
JSON 算法 API
淘宝商品评论API接口核心解析,json数据返回
淘宝商品评论API是淘宝开放平台提供的数据服务接口,允许开发者通过编程方式获取指定商品的用户评价数据,包括文字、图片、视频评论及评分等。其核心价值在于:
|
1月前
|
域名解析 JSON API
【干货满满】如何处理requests库调用API接口时的异常情况
在调用 API 时,网络波动、服务器错误、参数异常等情况难以避免。本文提供一套系统化的异常处理方案,涵盖 requests 库常见异常类型、处理策略、实战代码与最佳实践,通过分类处理、重试机制与兜底策略,提升接口调用的稳定性与可靠性。