篮球数据【即时赔率】API调用示例代码,在线文档可注册下,篮球赔率接口详情页
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @API: 8.1篮球全场赔率接口
* @Website: https://www.feijing88.com
*/
public class BasketballOdds {
public static void main(String[] args) {
Odds odds = new Odds();
odds.parse(getContent());
// 为了展示只输出3条数据,实际不止
odds.getLeagueList().subList(0, 3).forEach(System.out::println);
odds.getMatchList().subList(0, 3).forEach(System.out::println);
odds.getRangFenList().subList(0, 3).forEach(System.out::println);
odds.getOuPeiList().subList(0, 3).forEach(System.out::println);
odds.getDaXiaoList().subList(0, 3).forEach(System.out::println);
}
/**
* 获取API返回内容
*
* Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容
*/
private static String getContent() {
try {
StringBuilder builder = new StringBuilder();
List<String> lines = Files.readAllLines(Paths.get("./src/main/resources/BasketballBet.xml"), StandardCharsets.UTF_8);
lines.forEach(line -> builder.append(line));
return builder.toString();
} catch (Throwable t) {
t.printStackTrace();
return "";
}
}
public static class Odds {
private List<League> leagueList;
private List<Match> matchList;
private List<RangFen> rangQiuList;
private List<OuPei> shengPingFuList;
private List<DaXiao> daXiaoList;
public void parse(String data) {
String[] parts = data.split("\\$");
leagueList = Arrays.stream(parts[0].split(";"))
.map(s -> {
League obj = new League();
obj.parse(s);
return obj;
})
.collect(Collectors.toList());
matchList = Arrays.stream(parts[1].split(";"))
.map(s -> {
Match obj = new Match();
obj.parse(s);
return obj;
})
.collect(Collectors.toList());
rangQiuList = Arrays.stream(parts[2].split(";"))
.map(s -> {
RangFen obj = new RangFen();
obj.parse(s);
return obj;
})
.collect(Collectors.toList());
shengPingFuList = Arrays.stream(parts[3].split(";"))
.map(s -> {
OuPei obj = new OuPei();
obj.parse(s);
return obj;
})
.collect(Collectors.toList());
daXiaoList = Arrays.stream(parts[4].split(";"))
.map(s -> {
DaXiao obj = new DaXiao();
obj.parse(s);
return obj;
})
.collect(Collectors.toList());
}
public List<League> getLeagueList() {
return leagueList;
}
public List<Match> getMatchList() {
return matchList;
}
public List<RangFen> getRangFenList() {
return rangQiuList;
}
public List<OuPei> getOuPeiList() {
return shengPingFuList;
}
public List<DaXiao> getDaXiaoList() {
return daXiaoList;
}
}
public static class League {
private String leagueId;
private int type;
private String leagueNameGb;
public void parse(String data) {
String[] values = data.split(",");
leagueId = values[0];
type = Integer.valueOf(values[1]);
leagueNameGb = values[3];
}
@Override
public String toString() {
return "League{" +
"leagueId='" + leagueId + '\'' +
", type=" + type +
", leagueNameGb='" + leagueNameGb + '\'' +
'}';
}
}
public static class Match {
private String matchId;
private String leagueId;
private String matchTime;
private String homeTeamId;
private String homeTeamNameGb;
private String homeTeamNameBig;
private String homeTeamNameEn;
private String homeTeamRank;
private String awayTeamId;
private String awayTeamNameGb;
private String awayTeamNameBig;
private String awayTeamNameEn;
private String awayTeamRank;
private int matchStatus;
private String homeTeamScore;
private String awayTeamScore;
public void parse(String data) {
String[] values = data.split(",");
matchId = values[0];
leagueId = values[1];
matchTime = values[2];
homeTeamId = values[3];
homeTeamNameGb = values[4];
homeTeamNameBig = values[5];
homeTeamNameEn = values[6];
homeTeamRank = values[7];
awayTeamId = values[8];
awayTeamNameGb = values[9];
awayTeamNameBig = values[10];
awayTeamNameEn = values[11];
awayTeamRank = values[12];
matchStatus = Integer.valueOf(values[13]);
homeTeamScore = values[14];
awayTeamScore = values[15];
}
@Override
public String toString() {
return "Match{" +
"matchId='" + matchId + '\'' +
", leagueId='" + leagueId + '\'' +
", matchTime='" + matchTime + '\'' +
", homeTeamId='" + homeTeamId + '\'' +
", homeTeamNameGb='" + homeTeamNameGb + '\'' +
", homeTeamNameBig='" + homeTeamNameBig + '\'' +
", homeTeamNameEn='" + homeTeamNameEn + '\'' +
", homeTeamRank=" + homeTeamRank +
", awayTeamId='" + awayTeamId + '\'' +
", awayTeamNameGb='" + awayTeamNameGb + '\'' +
", awayTeamNameBig='" + awayTeamNameBig + '\'' +
", awayTeamNameEn='" + awayTeamNameEn + '\'' +
", awayTeamRank=" + awayTeamRank +
", matchStatus=" + matchStatus +
", homeTeamScore=" + homeTeamScore +
", awayTeamScore=" + awayTeamScore +
'}';
}
}
public static class RangFen {
private String matchId;
private String companyId;
private String initHandicap;
private String initHomeOdds;
private String initAwayOdds;
private String handicap;
private String homeOdds;
private String awayOdds;
public void parse(String data) {
String[] values = data.split(",");
matchId = values[0];
companyId = values[1];
initHandicap = values[2];
initHomeOdds = values[3];
initAwayOdds = values[4];
handicap = values[5];
homeOdds = values[6];
awayOdds = values[7];
}
@Override
public String toString() {
return "RangFen{" +
"matchId='" + matchId + '\'' +
", companyId='" + companyId + '\'' +
", initHandicap='" + initHandicap + '\'' +
", initHomeOdds='" + initHomeOdds + '\'' +
", initAwayOdds='" + initAwayOdds + '\'' +
", handicap='" + handicap + '\'' +
", homeOdds='" + homeOdds + '\'' +
", awayOdds='" + awayOdds + '\'' +
'}';
}
}
public static class OuPei {
private String matchId;
private String companyId;
private String initHomeOdds;
private String initAwayOdds;
private String homeOdds;
private String awayOdds;
public void parse(String data) {
String[] values = data.split(",");
matchId = values[0];
companyId = values[1];
initHomeOdds = values[2];
initAwayOdds = values[3];
homeOdds = values[4];
awayOdds = values[5];
}
@Override
public String toString() {
return "OuPei{" +
"matchId='" + matchId + '\'' +
", companyId='" + companyId + '\'' +
", initHomeOdds='" + initHomeOdds + '\'' +
", initAwayOdds='" + initAwayOdds + '\'' +
", homeOdds='" + homeOdds + '\'' +
", awayOdds='" + awayOdds + '\'' +
'}';
}
}
public static class DaXiao {
private String matchId;
private String companyId;
private String initHandicap;
private String initBigOdds;
private String initSmallOdds;
private String handicap;
private String bigOdds;
private String smallOdds;
public void parse(String data) {
String[] values = data.split(",");
matchId = values[0];
companyId = values[1];
initHandicap = values[2];
initBigOdds = values[3];
initSmallOdds = values[4];
handicap = values[5];
bigOdds = values[6];
smallOdds = values[7];
}
@Override
public String toString() {
return "DaXiao{" +
"matchId='" + matchId + '\'' +
", companyId='" + companyId + '\'' +
", initHandicap='" + initHandicap + '\'' +
", initBigOdds='" + initBigOdds + '\'' +
", initSmallOdds='" + initSmallOdds + '\'' +
", handicap='" + handicap + '\'' +
", bigOdds='" + bigOdds + '\'' +
", smallOdds='" + smallOdds + '\'' +
'}';
}
}
}
API 返回数据如下(部分):
League{leagueId='57', type=2, leagueNameGb='友谊赛'}
League{leagueId='296', type=2, leagueNameGb='泛美男篮'}
League{leagueId='311', type=2, leagueNameGb='菲专员杯'}
Match{matchId='359773', leagueId='57', matchTime='1564732800000', homeTeamId='6497', homeTeamNameGb='图文巴登山者女篮', homeTeamNameBig='圖文巴登山者女籃', homeTeamNameEn='Toowoomba M W', homeTeamRank=, awayTeamId='2883', awayTeamNameGb='布里斯班斯巴达人女篮', awayTeamNameBig='布里斯班斯巴達人女籃', awayTeamNameEn='Brisbane Spartans (W)', awayTeamRank=, matchStatus=2, homeTeamScore=25, awayTeamScore=23}
Match{matchId='359771', leagueId='57', matchTime='1564734600000', homeTeamId='5762', homeTeamNameGb='麦凯陨石女篮', homeTeamNameBig='麥凱隕石女籃', homeTeamNameEn='Mackay Meteorettes (W)', homeTeamRank=, awayTeamId='5760', awayTeamNameGb='罗克汉普顿旋风女篮', awayTeamNameBig='羅克漢普頓旋風女籃', awayTeamNameEn='Rockhampton Cyclones (W)', awayTeamRank=, matchStatus=0, homeTeamScore=, awayTeamScore=}
Match{matchId='359772', leagueId='57', matchTime='1564740000000', homeTeamId='5812', homeTeamNameGb='图文巴登山者', homeTeamNameBig='圖文巴登山者', homeTeamNameEn='Toowoomba Mountaineers', homeTeamRank=, awayTeamId='2358', awayTeamNameGb='布里斯班斯巴达人', awayTeamNameBig='布里斯班斯巴達人', awayTeamNameEn='Brisbane Spartans', awayTeamRank=东南澳联4, matchStatus=0, homeTeamScore=, awayTeamScore=}
RangFen{matchId='358894', companyId='2', initHandicap='17.5', initHomeOdds='0.83', initAwayOdds='0.87', handicap='17.5', homeOdds='0.87', awayOdds='0.83'}
RangFen{matchId='358894', companyId='3', initHandicap='17.5', initHomeOdds='0.90', initAwayOdds='0.90', handicap='17.5', homeOdds='0.90', awayOdds='0.90'}
RangFen{matchId='358894', companyId='8', initHandicap='11.5', initHomeOdds='0.83', initAwayOdds='0.83', handicap='17.5', homeOdds='0.83', awayOdds='0.83'}
OuPei{matchId='358894', companyId='2', initHomeOdds='1.04', initAwayOdds='8.40', homeOdds='1.04', awayOdds='8.40'}
OuPei{matchId='358894', companyId='9', initHomeOdds='1.154', initAwayOdds='4.80', homeOdds='1.056', awayOdds='8.00'}
OuPei{matchId='358894', companyId='8', initHomeOdds='1.14', initAwayOdds='5.00', homeOdds='1.03', awayOdds='9.50'}
DaXiao{matchId='358894', companyId='5', initHandicap='143.5', initBigOdds='0.87', initSmallOdds='0.83', handicap='141.5', bigOdds='0.79', smallOdds='0.91'}
DaXiao{matchId='358894', companyId='6', initHandicap='141.5', initBigOdds='0.88', initSmallOdds='0.88', handicap='142.5', bigOdds='0.70', smallOdds='1.06'}
DaXiao{matchId='358894', companyId='11', initHandicap='143.5', initBigOdds='0.83', initSmallOdds='0.83', handicap='141.5', bigOdds='0.83', smallOdds='0.83'}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。