资讯专栏INFORMATION COLUMN

如果获取篮球联赛数据?

kycool / 611人阅读

摘要:分享之前调用过的飞鲸体育数据,可注册使用下篮球联赛数据联赛赛事资料获取返回内容这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容返回数据如下部分美国男子职业篮球联赛美國男子職業籃球聯賽美国美国女子职业篮球联赛美國女子職業

分享之前调用过的飞鲸体育数据api,可注册使用下篮球联赛数据

</>复制代码

  1. import javax.xml.bind.JAXBContext;
  2. import javax.xml.bind.Unmarshaller;
  3. import javax.xml.bind.annotation.XmlElement;
  4. import javax.xml.bind.annotation.XmlRootElement;
  5. import java.io.ByteArrayInputStream;
  6. import java.nio.charset.StandardCharsets;
  7. import java.nio.file.Files;
  8. import java.nio.file.Paths;
  9. import java.util.List;
  10. /**
  11. * @API: 4.联赛、赛事资料
  12. * @Website: https://www.feijing88.com
  13. */
  14. public class BasketballLeagueInfo {
  15. public static void main(String[] args) {
  16. try {
  17. String content = getContent();
  18. JAXBContext jaxbContext = JAXBContext.newInstance(LeagueList.class);
  19. Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
  20. LeagueList list = (LeagueList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes()));
  21. list.getLeagueList().forEach(System.out::println);
  22. } catch (Throwable t) {
  23. t.printStackTrace();
  24. }
  25. }
  26. /**
  27. * 获取API返回内容
  28. *

  29. * Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容
  30. */
  31. private static String getContent() {
  32. try {
  33. StringBuilder builder = new StringBuilder();
  34. List lines = Files.readAllLines(Paths.get("./src/main/resources/BasketballLeagueInfo.xml"), StandardCharsets.UTF_8);
  35. lines.forEach(builder::append);
  36. return builder.toString();
  37. } catch (Throwable t) {
  38. t.printStackTrace();
  39. return "";
  40. }
  41. }
  42. @XmlRootElement(name = "list")
  43. public static class LeagueList {
  44. @XmlElement(name = "match")
  45. private List leagueList;
  46. public List getLeagueList() {
  47. return leagueList;
  48. }
  49. }
  50. public static class League {
  51. @XmlElement(name = "id")
  52. private String id;
  53. @XmlElement(name = "short")
  54. private String nameShort;
  55. @XmlElement(name = "gb")
  56. private String nameGb;
  57. @XmlElement(name = "big")
  58. private String nameBig;
  59. @XmlElement(name = "en")
  60. private String nameEn;
  61. @XmlElement(name = "type")
  62. private int type;
  63. @XmlElement(name = "Curr_matchSeason")
  64. private String currentSeason;
  65. @XmlElement(name = "countryID")
  66. private String countryId;
  67. @XmlElement(name = "country")
  68. private String countryName;
  69. @XmlElement(name = "curr_year")
  70. private int currentYear;
  71. @XmlElement(name = "curr_month")
  72. private int currentMonth;
  73. @XmlElement(name = "sclass_kind")
  74. private int kind;
  75. @Override
  76. public String toString() {
  77. return "League{" +
  78. "id="" + id + """ +
  79. ", nameShort="" + nameShort + """ +
  80. ", nameGb="" + nameGb + """ +
  81. ", nameBig="" + nameBig + """ +
  82. ", nameEn="" + nameEn + """ +
  83. ", type=" + type +
  84. ", currentSeason="" + currentSeason + """ +
  85. ", countryId="" + countryId + """ +
  86. ", countryName="" + countryName + """ +
  87. ", currentYear=" + currentYear +
  88. ", currentMonth=" + currentMonth +
  89. ", kind=" + kind +
  90. "}";
  91. }
  92. }
  93. }

API 返回数据如下(部分):

</>复制代码

  1. League{id="1", nameShort="NBA", nameGb="美国男子职业篮球联赛", nameBig="美國男子職業籃球聯賽", nameEn="National Basketball Association", type=4, currentSeason="18-19", countryId="1", countryName="美国", currentYear=2011, currentMonth=11, kind=1}
  2. 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}
  3. 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}
  4. 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}
  5. League{id="7", nameShort="Euro", nameGb="欧洲篮球冠军联赛", nameBig="歐洲籃球冠軍聯賽", nameEn="EURO", type=4, currentSeason="19-20", countryId="16", countryName="欧洲赛事", currentYear=2011, currentMonth=10, kind=2}
  6. 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}
  7. 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}
  8. League{id="10", nameShort="篮世杯", nameGb="篮球世界杯", nameBig="籃球世界盃", nameEn="FIBA Basketball World Cup", type=4, currentSeason="19", countryId="20", countryName="国际赛事", currentYear=2010, currentMonth=8, kind=2}
  9. League{id="13", nameShort="世女俱", nameGb="世女俱", nameBig="世女俱", nameEn="The world women Club", type=4, currentSeason="17", countryId="20", countryName="国际赛事", currentYear=2007, currentMonth=10, kind=2}

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/106326.html

相关文章

  • 如果获取篮球联赛数据

    摘要:分享之前调用过的飞鲸体育数据,可注册使用下篮球联赛数据联赛赛事资料获取返回内容这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容返回数据如下部分美国男子职业篮球联赛美國男子職業籃球聯賽美国美国女子职业篮球联赛美國女子職業 分享之前调用过的飞鲸体育数据api,可注册使用下篮球联赛数据 import javax.xml.bind.JAXBContext; import j...

    JerryC 评论0 收藏0
  • python在Scikit-learn中用决策树和随机森林预测NBA获胜者

    摘要:在本文中,我们将以的决策树和随机森林预测获胜者。用决策树和随机森林预测获胜者导入数据集并解析日期导入熊猫作为。这将帮助我们查看决策树分类器的预测是否正确。混淆矩阵显示了我们决策树的正确和不正确的分类。 showImg(https://segmentfault.com/img/bVbcr26?w=750&h=383); 在本文中,我们将以Scikit-learn的决策树和随机森林预测NB...

    learning 评论0 收藏0
  • 如何使用 Python 创建一个 NBA 得分图?

    摘要:本文意在创建一个得分图,该图同时描绘了从场上不同位置投篮得分的百分比和投篮次数,这和个人网站上的帖子类似。接下来,我们需要绘制一个包含得分图的篮球场图。球员照片会出现在得分图的右下角。的解决办法是将命中率与联赛平均分关联。 本文意在创建一个得分图,该图同时描绘了从场上不同位置投篮得分的百分比和投篮次数,这和 Austin Clemen 个人网站上的帖子 http://www.austi...

    KitorinZero 评论0 收藏0
  • 世界杯押注还得看技术流,这个预测AI把赔率也算上了

    摘要:世界杯小组赛将收官,你还依然信吗冷门频出,黑马击败豪强。以本届世界杯开幕战俄罗斯对阵沙特阿拉伯的比赛为例,两队上次交手是在年的一场友谊赛,距今已经年。然后进入第二步,预测回报率导向。在足球领域,这个回报率已非常不俗。 世界杯小组赛将收官,你还依然信AI吗?冷门频出,黑马击败豪强。不少AI模型始料未及。到底还能不能愉快找到科学规律?或者说足球比赛乃至其他竞技体育赛事,数据科学家在AI加持下,究...

    walterrwu 评论0 收藏0

发表评论

0条评论

kycool

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<