https://www.xxe.io/
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: 11.单盘口赔率:实时赔率接口
- @Website: https://www.xxe.io/
*/
public class FootballOdds {
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.getRangQiuList().subList(0, 3).forEach(System.out::println);
odds.getShengPingFuList().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/FootballBet.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<RangQiu> rangQiuList;
private List<ShengPingFu> 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 -> {
RangQiu obj = new RangQiu();
obj.parse(s);
return obj;
})
.collect(Collectors.toList());
shengPingFuList = Arrays.stream(parts[3].split(";"))
.map(s -> {
ShengPingFu obj = new ShengPingFu();
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<RangQiu> getRangQiuList() {
return rangQiuList;
}
public List<ShengPingFu> getShengPingFuList() {
return shengPingFuList;
}
public List<DaXiao> getDaXiaoList() {
return daXiaoList;
}
}
public static class League {
private String leagueId;
private int type;
private String leagueNameGb;
private String leagueNameBig;
private String leagueNameEn;
public void parse(String data) {
String[] values = data.split(",");
leagueId = values[0];
type = Integer.valueOf(values[1]);
leagueNameGb = values[3];
leagueNameBig = values[4];
leagueNameEn = values[5];
}
@Override
public String toString() {
return "League{" +
"leagueId='" + leagueId + '\'' +
", type=" + type +
", leagueNameGb='" + leagueNameGb + '\'' +
", leagueNameBig='" + leagueNameBig + '\'' +
", leagueNameEn='" + leagueNameEn + '\'' +
'}';
}
}
public static class Match {
private String matchId;
private String leagueId;
private String matchTime;
private String startTime;
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 int homeTeamScore;
private int awayTeamScore;
private int homeRed;
private int awayRed;
private int homeYellow;
private int awayYellow;
public void parse(String data) {
String[] values = data.split(",");
matchId = values[0];
leagueId = values[1];
matchTime = values[2];
startTime = values[3];
homeTeamId = values[4];
homeTeamNameGb = values[5];
homeTeamNameBig = values[6];
homeTeamNameEn = values[7];
homeTeamRank = values[8];
awayTeamId = values[9];
awayTeamNameGb = values[10];
awayTeamNameBig = values[11];
awayTeamNameEn = values[12];
awayTeamRank = values[13];
matchStatus = Integer.valueOf(values[14]);
homeTeamScore = Integer.valueOf(values[15]);
awayTeamScore = Integer.valueOf(values[16]);
homeRed = Integer.valueOf(values[20]);
awayRed = Integer.valueOf(values[21]);
homeYellow = Integer.valueOf(values[22]);
awayYellow = Integer.valueOf(values[23]);
}
@Override
public String toString() {
return "Match{" +
"matchId='" + matchId + '\'' +
", leagueId='" + leagueId + '\'' +
", matchTime='" + matchTime + '\'' +
", startTime='" + startTime + '\'' +
", 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 +
", homeRed=" + homeRed +
", awayRed=" + awayRed +
", homeYellow=" + homeYellow +
", awayYellow=" + awayYellow +
'}';
}
}
public static class RangQiu {
private String matchId;
private String companyId;
private String initHandicap;
private String initHomeOdds;
private String initAwayOdds;
private String handicap;
private String homeOdds;
private String awayOdds;
private String disable;
private String time;
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];
disable = values[8];
time = values[10];
}
@Override
public String toString() {
return "RangQiu{" +
"matchId='" + matchId + '\'' +
", companyId='" + companyId + '\'' +
", initHandicap='" + initHandicap + '\'' +
", initHomeOdds='" + initHomeOdds + '\'' +
", initAwayOdds='" + initAwayOdds + '\'' +
", handicap='" + handicap + '\'' +
", homeOdds='" + homeOdds + '\'' +
", awayOdds='" + awayOdds + '\'' +
", disable='" + disable + '\'' +
", time='" + time + '\'' +
'}';
}
}
public static class ShengPingFu {
private String matchId;
private String companyId;
private String initHomeOdds;
private String initDrawOdds;
private String initAwayOdds;
private String homeOdds;
private String drawOdds;
private String awayOdds;
private String time;
private String disable;
public void parse(String data) {
String[] values = data.split(",");
matchId = values[0];
companyId = values[1];
initHomeOdds = values[2];
initDrawOdds = values[3];
initAwayOdds = values[4];
homeOdds = values[5];
drawOdds = values[6];
awayOdds = values[7];
time = values[8];
disable = values[9];
}
@Override
public String toString() {
return "ShengPingFu{" +
"matchId='" + matchId + '\'' +
", companyId='" + companyId + '\'' +
", initHomeOdds='" + initHomeOdds + '\'' +
", initDrawOdds='" + initDrawOdds + '\'' +
", initAwayOdds='" + initAwayOdds + '\'' +
", homeOdds='" + homeOdds + '\'' +
", drawOdds='" + drawOdds + '\'' +
", awayOdds='" + awayOdds + '\'' +
", time='" + time + '\'' +
", disable='" + disable + '\'' +
'}';
}
}
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;
private String time;
private String disable;
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];
time = values[8];
disable = values[9];
}
@Override
public String toString() {
return "DaXiao{" +
"matchId='" + matchId + '\'' +
", companyId='" + companyId + '\'' +
", initHandicap='" + initHandicap + '\'' +
", initBigOdds='" + initBigOdds + '\'' +
", initSmallOdds='" + initSmallOdds + '\'' +
", handicap='" + handicap + '\'' +
", bigOdds='" + bigOdds + '\'' +
", smallOdds='" + smallOdds + '\'' +
", time='" + time + '\'' +
", disable='" + disable + '\'' +
'}';
}
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。