足球即时比分api示例代码

这里简单介绍下之前参与项目过程调取的足球比分api示例代码,在线文档查看

        val elements = fetchElementList("http://interface.win007.com/zq/today.aspx", "match")

        return elements.map {
            val leagueMix = MixString(it["league"])
            val homeTeamMix = MixString(it["home"])
            val awayTeamMix = MixString(it["away"])
            FootballMatch(
                matchId = it["ID"],
                level = it["level"].toIntOr(),
                leagueId = it["leagueID"],
                leagueType = it["kind"].toIntOr(1),
                leagueName = leagueMix[2],
                matchTime = it["time"].parseSlashTimestamp(),
                startTime = it["time2"].parseSlashTimestamp(),
                status = it["state"].toIntOr(),
                homeTeamId = homeTeamMix[3],
                awayTeamId = awayTeamMix[3],
                homeTeamName = homeTeamMix[2],
                awayTeamName = awayTeamMix[2],
                homeTeamScore = it["homeScore"].toIntOr(),
                awayTeamScore = it["awayScore"].toIntOr(),
                homeTeamHalfScore = it["bc1"].toIntOr(),
                awayTeamHalfScore = it["bc2"].toIntOr(),
                homeTeamRed = it["red1"].toIntOr(),
                awayTeamRed = it["red2"].toIntOr(),
                homeTeamYellow = it["yellow1"].toIntOr(),
                awayTeamYellow = it["yellow2"].toIntOr(),
                homeCorner = it["corner1"].toIntOr(),
                awayCorner = it["corner2"].toIntOr(),
                isNeutral = it["zl"].toBoolean(),
                hasLineup = it["lineup"].toIntOr() == 1
            )
        }
    }

API部分返回示例:

    source: String,
    delimiters: String = ","
) {
    val list: List<String> = source.split(delimiters)

    operator fun get(index: Int): String = list.getOrNull(index) ?: ""
}
上一篇:MongoVE连接MongoDB 不显示数据问题


下一篇:八边形