Beispiel #1
0
def get_history(url):
    """Getting history from url"""
    soup = uf.get_soup(url)

    # : adding names
    res = []
    for i in soup.findAll(attrs={'class': 'match__team__name'}):
        res.append(i.text)

    # : getting history
    logo = soup.find(attrs={'class': re.compile('match__timeline__team__icon')})['src']
    soup2 = soup.find(attrs={'class': 'table match__history__table'})
    if soup2 is None:
        return None
    soup2 = soup2.findAll('tr', limit=2)
    h = 0
    for i in soup2:
        h += get_winner(logo, i)
    h /= 4
    res.append(h)

    #: adding result
    res += uf.get_results(soup)

    return res
def get_form(url):
    """Gets teams and their forms from url"""
    soup = uf.get_soup(url)
    res = []

    #: adding names
    res += uf.get_names(soup)

    # : counting form
    history = []
    for i in soup.findAll(
            attrs={'class': re.compile('(_win)|(_tie)|(_lose)')}):
        history.append(i['class'])
    if len(history) < 10:
        return None
    elif len(history) < 12:
        start1 = 0
        start2 = 5
    else:
        start1 = 1
        start2 = 7
    form1 = 0
    form2 = 0
    for i in range(start1, start1 + 5):
        if history[i] == ['_win']:
            form1 += 2
        elif history[i] == ['_tie']:
            form1 += 1
    for i in range(start2, start2 + 5):
        if history[i] == ['_win']:
            form2 += 2
        elif history[i] == ['_tie']:
            form2 += 1
    form1 /= 10
    form2 /= 10
    res = res + [form1] + [form2]

    #: adding result
    res += uf.get_results(soup)

    return res
def get_form(url):
    """Gets teams and their forms from url"""
    soup = uf.get_soup(url)
    res = []

    #: adding names
    res += uf.get_names(soup)

    # : counting form
    history = []
    for i in soup.findAll(attrs={"class": re.compile("(_win)|(_tie)|(_lose)")}):
        history.append(i["class"])
    if len(history) < 10:
        return None
    elif len(history) < 12:
        start1 = 0
        start2 = 5
    else:
        start1 = 1
        start2 = 7
    form1 = 0
    form2 = 0
    for i in range(start1, start1 + 5):
        if history[i] == ["_win"]:
            form1 += 2
        elif history[i] == ["_tie"]:
            form1 += 1
    for i in range(start2, start2 + 5):
        if history[i] == ["_win"]:
            form2 += 2
        elif history[i] == ["_tie"]:
            form2 += 1
    form1 /= 10
    form2 /= 10
    res = res + [form1] + [form2]

    #: adding result
    res += uf.get_results(soup)

    return res