摘要:分享籃球即時(shí)比分接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊(cè)下即時(shí)變化的比分?jǐn)?shù)據(jù)獲取返回內(nèi)容這里為了方便測(cè)試我使用了一份本地文件,使用時(shí)應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分
分享籃球即時(shí)比分api接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊(cè)下https://www.feijing88.com/bas...
package com.huaying.demo.basketball; import javax.xml.bind.JAXBContext; 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; import java.util.stream.Collectors; /** * @API: 2.即時(shí)變化的比分?jǐn)?shù)據(jù) * @Website: https://www.feijing88.com */ public class BasketballChange { public static void main(String[] args) { try { String content = getContent(); JAXBContext jaxbContext = JAXBContext.newInstance(ChangeList.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); ChangeList list = (ChangeList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes())); list.getChangeList().forEach(System.out::println); } catch (Throwable t) { t.printStackTrace(); } } /** * 獲取API返回內(nèi)容 ** Note: 這里為了方便測(cè)試我使用了一份本地文件,使用時(shí)應(yīng)替換為真實(shí)接口返回內(nèi)容 */ private static String getContent() { try { StringBuilder builder = new StringBuilder(); List
lines = Files.readAllLines(Paths.get("./src/main/resources/BasketballChange.xml"), StandardCharsets.UTF_8); lines.forEach(line -> builder.append(line)); return builder.toString(); } catch (Throwable t) { t.printStackTrace(); return ""; } } @XmlRootElement(name = "c") public static class ChangeList { @XmlElement(name = "h") private List itemList; public List getChangeList() { return itemList.stream().map(s -> { Change change = new Change(); change.parse(s); return change; }).collect(Collectors.toList()); } } public static class Change { private String matchId; private int matchStatus; private String remainTime; private int homeScore; private int homeScoreFirst; private int homeScoreSecond; private int homeScoreThird; private int homeScoreFourth; private int homeScoreFirstOT; private int homeScoreSecondOT; private int homeScoreThirdOT; private int awayScore; private int awayScoreFirst; private int awayScoreSecond; private int awayScoreThird; private int awayScoreFourth; private int awayScoreFirstOT; private int awayScoreSecondOT; private int awayScoreThirdOT; public void parse(String data) { String[] values = data.split("^"); matchId = values[0]; matchStatus = parseInt(values[1]); remainTime = values[2]; homeScore = parseInt(values[3]); homeScoreFirst = parseInt(values[5]); homeScoreSecond = parseInt(values[7]); homeScoreThird = parseInt(values[9]); homeScoreFourth = parseInt(values[11]); homeScoreFirstOT = parseInt(values[16]); homeScoreSecondOT = parseInt(values[18]); homeScoreThirdOT = parseInt(values[20]); awayScore = parseInt(values[4]); awayScoreFirst = parseInt(values[6]); awayScoreSecond = parseInt(values[8]); awayScoreThird = parseInt(values[10]); awayScoreFourth = parseInt(values[12]); awayScoreFirstOT = parseInt(values[17]); awayScoreSecondOT = parseInt(values[19]); awayScoreThirdOT = parseInt(values[21]); } private int parseInt(String data) { return data == null || data.isEmpty() ? 0 : Integer.valueOf(data); } @Override public String toString() { return "Change{" + "matchId="" + matchId + """ + ", matchStatus=" + matchStatus + ", remainTime="" + remainTime + """ + ", homeScore=" + homeScore + ", homeScoreFirst=" + homeScoreFirst + ", homeScoreSecond=" + homeScoreSecond + ", homeScoreThird=" + homeScoreThird + ", homeScoreFourth=" + homeScoreFourth + ", homeScoreFirstOT=" + homeScoreFirstOT + ", homeScoreSecondOT=" + homeScoreSecondOT + ", homeScoreThirdOT=" + homeScoreThirdOT + ", awayScore=" + awayScore + ", awayScoreFirst=" + awayScoreFirst + ", awayScoreSecond=" + awayScoreSecond + ", awayScoreThird=" + awayScoreThird + ", awayScoreFourth=" + awayScoreFourth + ", awayScoreFirstOT=" + awayScoreFirstOT + ", awayScoreSecondOT=" + awayScoreSecondOT + ", awayScoreThirdOT=" + awayScoreThirdOT + "}"; } } }
API 返回?cái)?shù)據(jù)如下(部分):
Change{matchId="358749", matchStatus=-1, remainTime="", homeScore=86, homeScoreFirst=28, homeScoreSecond=22, homeScoreThird=13, homeScoreFourth=23, homeScoreFirstOT=0, homeScoreSecondOT=0, homeScoreThirdOT=0, awayScore=52, awayScoreFirst=20, awayScoreSecond=11, awayScoreThird=14, awayScoreFourth=7, awayScoreFirstOT=0, awayScoreSecondOT=0, awayScoreThirdOT=0} Change{matchId="358761", matchStatus=2, remainTime="06:50", homeScore=20, homeScoreFirst=14, homeScoreSecond=6, homeScoreThird=0, homeScoreFourth=0, homeScoreFirstOT=0, homeScoreSecondOT=0, homeScoreThirdOT=0, awayScore=44, awayScoreFirst=31, awayScoreSecond=13, awayScoreThird=0, awayScoreFourth=0, awayScoreFirstOT=0, awayScoreSecondOT=0, awayScoreThirdOT=0}
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/45255.html
摘要:分享籃球即時(shí)比分接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊(cè)下即時(shí)變化的比分?jǐn)?shù)據(jù)獲取返回內(nèi)容這里為了方便測(cè)試我使用了一份本地文件,使用時(shí)應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分 分享籃球即時(shí)比分api接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊(cè)下https://www.feijing88.com/bas... package com.huaying.demo.basketball;...
摘要:分享籃球即時(shí)比分接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊(cè)下即時(shí)變化的比分?jǐn)?shù)據(jù)獲取返回內(nèi)容這里為了方便測(cè)試我使用了一份本地文件,使用時(shí)應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分 分享籃球即時(shí)比分api接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊(cè)下https://www.feijing88.com/bas... package com.huaying.demo.basketball;...
摘要:籃球數(shù)據(jù)即時(shí)賠率調(diào)用示例代碼,在線文檔可注冊(cè)下,籃球賠率接口詳情頁籃球全場(chǎng)賠率接口為了展示只輸出條數(shù)據(jù),實(shí)際不止獲取返回內(nèi)容這里為了方便測(cè)試我使用了一份本地文件,使用時(shí)應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分友誼賽泛美男籃菲專員 籃球數(shù)據(jù)【即時(shí)賠率】API調(diào)用示例代碼,在線文檔可注冊(cè)下,籃球賠率接口詳情頁 import java.nio.charset.StandardCharsets...
摘要:籃球數(shù)據(jù)即時(shí)賠率調(diào)用示例代碼,在線文檔可注冊(cè)下,籃球賠率接口詳情頁籃球全場(chǎng)賠率接口為了展示只輸出條數(shù)據(jù),實(shí)際不止獲取返回內(nèi)容這里為了方便測(cè)試我使用了一份本地文件,使用時(shí)應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分友誼賽泛美男籃菲專員 籃球數(shù)據(jù)【即時(shí)賠率】API調(diào)用示例代碼,在線文檔可注冊(cè)下,籃球賠率接口詳情頁 import java.nio.charset.StandardCharsets...
閱讀 2178·2023-04-25 19:06
閱讀 1375·2021-11-17 09:33
閱讀 1767·2019-08-30 15:53
閱讀 2582·2019-08-30 14:20
閱讀 3541·2019-08-29 12:58
閱讀 3534·2019-08-26 13:27
閱讀 501·2019-08-26 12:23
閱讀 485·2019-08-26 12:22