Beispiel #1
0
def get_score(team1, team2):
    score = ""
    print(team1)
    print(team2)
    soup = data_request()
    teamlist1 = get_teamlist1(soup)
    teamlist2 = get_teamlist2(soup)
    print(teamlist1)
    print(teamlist2)
    match_id = get_match_id(soup)
    if team1 != "" and team2 != "" and team1 in teamlist1:
        ind = teamlist1.index(team1)
        if teamlist2[ind] == team2:
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match between " + team1 + " and " + team2

    elif team1 != "" and team2 != "" and team1 in teamlist2:
        ind = teamlist2.index(team1)
        if teamlist1[ind] == team2:
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match between " + team1 + " and " + team2

    elif team1 != "" and team2 == "":
        if team1 in teamlist1:
            ind = teamlist1.index(team1)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        elif team1 in teamlist2:
            ind = teamlist2.index(team1)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match going on for " + team1

    elif team1 == "" and team2 != "":
        if team2 in teamlist1:
            ind = teamlist1.index(team2)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        elif team2 in teamlist2:
            ind = teamlist2.index(team2)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match going on for " + team2

    elif team1 == "" and team2 == "":
        score = "Please tell me the team name, whose score you want to know"
    return score