当前位置: 首页 > 后端技术 > PHP

足球【赛程结果】数据获取方法

时间:2023-03-29 19:14:21 PHP

野子电竞数据官网改版https://www.xxe.io/全新登场importjavax.xml.bind.JAXBContext;importjavax.xml.bind.Unmarshaller;importjavax.xml.bind.annotation.XmlElement;importjavax.xml.bind.annotation.XmlRootElement;导入java.io.ByteArrayInputStream;导入java.nio.charset.StandardCharsets;导入java.nio.file.Files;导入java.nio.file.Paths;导入java.util.List;/**@API:4.调度结果@Website:https://www.xxe.io/*/publicclassFootballResult{publicstaticvoidmain(String[]args){try{Stringcontent=getContent();JAXBContextjaxbContext=JAXBContext.newInstance(MatchList.class);解组器unmarshaller=jaxbContext.createUnmarshaller();MatchListmatchList=(MatchList)unmarshaller.unmarshal(newByteArrayInputStream(content.getBytes()));matchList.getMatchList().forEach(item->System.out.println(item));}catch(Throwablet){t.printStackTrace();}}/***获取API的返回内容**注意:这里为了方便测试我使用了本地文件,返回时要替换成真实的接口返回内容*/privatestaticStringgetContent(){try{StringBuilderbuilder=newStringBuilder();Listlines=Files.readAllLines(Paths.get("./src/main/resources/FootballResult.xml"),StandardCharsets.UTF_8);lines.forEach(line->builder.append(line));返回builder.toString();}catch(Throwablet){t.printStackTrace();返回””;}}@XmlRootElement(name="list")publicstaticclassMatchList{privateListmatchList;@XmlElement(name="match")publicListgetMatchList(){returnmatchList;}publicvoidsetMatchList(ListmatchList){this.matchList=matchList;}}@XmlRootElementpublicstaticclassMatch{@XmlElement(name="a")privateintmatchId;@XmlElement(name="c")privateStringleagueInfo;@XmlElement(name="d")privateStringmatchTime;@XmlElement(name="e")privateintsub类型;@XmlElement(name="f")privateintmatchStatus;@XmlElement(name="h")privateStringhomeTeamInfo;@XmlElement(name="i")privateStringawayTeamInfo;@XmlElement(name="j")privateinthomeScore;@XmlElement(name="k")privateintawayScore;@XmlElement(name="l")privateinthomeScoreFirstHalf;@XmlElement(name="m")privateintawayScroeFirstHalf;@XmlElement(name="n")privateinthomeRed;@XmlElement(name="o")privateintawayRed;@XmlElement(name="p")privateinthomeRank;@XmlElement(name="q")privateintawayRank;@XmlElement(name="s")privateStringround;@XmlElement(name="t")私有字符串地址;@XmlElement(name="x")私有字符串季节;@XmlElement(name="y")私有字符串组;@XmlElement(name="z")私有字符串是中性的;@XmlElement(name="subID")privateStringsubLeagueId;@XmlElement(name="yellow")privateintyellow;@OverridepublicStringtoString(){return"Match{"+"matchId="+matchId+",leagueInfo='"+leagueInfo+'\''+",matchTime='"+matchTime+'\''+",subType="+subType+",matchStatus="+matchStatus+",homeTeamInfo='"+homeTeamInfo+'\''+",awayTeamInfo='"+awayTeamInfo+'\''+",homeScore="+homeScore+",awayScore="+awayScore+",homeScoreFirstHalf="+homeScoreFirstHalf+",awayScroeFirstHalf="+awayScroeFirstHalf+",homeRed="+homeRed+",awayRed="+awayRed+",homeRank="+homeRank+",awayRank="+awayRank+",round='"+round+'\''+",address='"+address+'\''+",season='"+season+'\''+",group='"+group+'\''+",isNeutral='"+isNeutral+'\''+",subLeagueId='"+subLeagueId+'\''+",黄色="+黄色+'}';}publicintgetMatchId(){返回matchId;}publicStringgetLeagueInfo(){返回联赛信息;}publicStringgetMatchTime(){返回匹配时间;}publicintgetSubType(){返回子类型;}publicintgetMatchStatus(){返回匹配状态;}publicStringgetHomeTeamInfo(){returnhomeTeamInfo;}publicStringgetAwayTeamInfo(){returnawayTeamInfo;}publicintgetHomeScore(){返回homeScore;}publicintgetAwayScore(){返回awayScore;}publicintgetHomeScoreFirstHalf(){返回homeScoreFirstHalf;}publicintgetAwayScroeFirstHalf(){返回awayScroeFirstHalf;}酒吧licintgetHomeRed(){返回homeRed;}publicintgetAwayRed(){返回awayRed;}publicintgetHomeRank(){返回homeRank;}publicintgetAwayRank(){返回awayRank;}publicStringgetRound(){返回回合;}publicStringgetAddress(){返回地址;}publicStringgetSeason(){返回季节;}publicStringgetGroup(){返回组;}publicStringgetIsNeutral(){返回是中性的;}publicStringgetSubLeagueId(){返回subLeagueId;}publicintgetYellow(){返回黄色;}}}