Пример #1
0
    def find_champion_stats_rank(soup):
        win_ratio = ut.rss(
            soup.find("div", class_="champion-stats-trend-rate").text)
        text = ut.rss(
            soup.find("div", class_="champion-stats-trend-average").text)

        if win_ratio == "%":
            return None
        return f"{win_ratio} {text}"
Пример #2
0
    def find_tier_box(soup):
        tier_box = soup.find("div", class_="TierBox")
        tier_info = tier_box.find("div", class_="TierInfo")
        img = tier_box.find("div", class_="Medal").img["src"]
        elo = tier_box.find("div", class_="TierRank").text
        win_ratio = ""

        if ut.rss(elo) != "Unranked":
            elo += " " + ut.rss(
                tier_info.find("span", class_="LeaguePoints").text)
            win_ratio = OpggCrawler.find_win_ratio(tier_info)

        return {"elo_icon": "http:" + img, "win_ratio": win_ratio, "elo": elo}
Пример #3
0
 def find_champions(soup):
     champions = list()
     if soup.find(class_="MostChampionContent") is not None:
         most_played_champs = soup.find_all(
             "div",
             class_=lambda class_: class_ and "ChampionBox" in class_)
         for champ_box in most_played_champs:
             c_name = champ_box.find("div", class_="ChampionName")["title"]
             c_icon = "https:" + champ_box.find("div",
                                                class_="Face").a.img["src"]
             c_played = OpggCrawler.find_played(
                 champ_box.find("div", class_="Played"))
             c_kda = OpggCrawler.find_kda(
                 champ_box.find("div", class_="PersonalKDA"))
             c_cs = ut.rss(
                 champ_box.find(
                     "div", class_="ChampionMinionKill").text).split()[1]
             champions.append(
                 SummonerChampion(
                     name=c_name,
                     icon=c_icon,
                     win_ratio=c_played["win_ratio"],
                     games=c_played["games"],
                     kda=c_kda,
                     cs=c_cs,
                 ))
     return champions
Пример #4
0
    def find_runes(soup):
        rune_table = soup.find("tbody", class_="ChampionKeystoneRune-1").tr
        tree_types = ut.rss(
            soup.find("div", class_="champion-stats-summary-rune__name").text)
        tree_types = tree_types.split(" + ")

        runes = []
        stats = []
        for perk_page in rune_table.find_all("div", class_="perk-page__row"):
            active_rune = perk_page.find_all("div",
                                             class_="perk-page__item--active")
            if active_rune is not None and len(active_rune) != 0:
                runes.append(active_rune[0].img["alt"])

        for shard_row in rune_table.find_all("div", class_="fragment__row"):
            for img in shard_row.find_all("img"):
                if img['class'][0] == 'active':
                    stats.append(OpggCrawler.find_shard_name(img["src"]))

        summoners_con = soup.find("td", class_="champion-overview__data")
        summoners = [
            OpggCrawler.find_spell_name(sspell.img['src']) for sspell in
            summoners_con.find_all("li", class_="champion-stats__list__item")
        ]

        return RunePage(
            types=tree_types,
            keystone=runes[0],
            primaries=runes[1:4],
            secondaries=runes[4:],
            stats=stats,
            summoners=summoners,
        )
Пример #5
0
 def find_ladder_rank(soup):
     ladder_con = soup.find("div", class_="LadderRank")
     if ladder_con is not None:
         top = ut.rss(ladder_con.a.contents[2])
         ranking = ladder_con.a.span.text
         ladder_rank = f"Ladder Rank {ranking} {top}"
     else:
         ladder_rank = ""
     return ladder_rank
Пример #6
0
 def find_counters(soup):
     counters_con = soup.find("table",
                              class_="champion-stats-header-matchup__table")
     return ut.rss(counters_con.text).replace(
         "Win Ratio", " Win Ratio ").split("Counter")