async def update_region(ctx, *args): logger.info("received user command scrape " + str(args)) arg_list = list(args) if len(arg_list) == 1: config.set_region(arg_list[0]) new_region = config.get_region() await ctx.send(f"Region setting has been changed to {new_region}") else: await ctx.send("Usage is !setregion region")
def build_opgg_multi_link(self): """ construct a valid op.gg multi link for the given summoner names :return: String, url to the multilink for the given names """ region = config.get_region() base_url = f"https://{region}.op.gg/multi/query=" multi_link = base_url for player in self.player_list: multi_link += player.summoner_name.replace(" ", "") multi_link += "%2C" return multi_link
def test_config(): import os os.chdir("..") from utils import scrap_config as config region = "EUW" timezone = "CET" config.set_region(region) config.set_timezone(timezone) assert config.get_region() == region assert config.get_timezone() == timezone
def stalk_player_leagueofgraphs(sum_name): """ Use leagueofgraphs web page to find the the current soloQ ranking for the given summoner name :param sum_name: Str, the summoner name of a league game account :return: Str, string version of the ranking """ region = config.get_region() base_url = f"https://www.leagueofgraphs.com/summoner/{region}/" url = base_url + sum_name.replace(" ", "+") page = requests.get(url) soup = bs4.BeautifulSoup(page.text, features="html.parser") elo = soup.find('span', class_="leagueTier") if elo is not None: return elo.text else: return "Unranked"
def stalk_player_mobalytics(sum_name): """ Use mobalytics web page to find the the current soloQ ranking for the given summoner name :param sum_name: Str, the summoner name of a league game account :return: Str, string version of the ranking """ region = config.get_region() base_url = f"https://lol.mobalytics.gg/summoner/{region}/" url = base_url + sum_name.replace(" ", "%20") page = requests.get(url) soup = bs4.BeautifulSoup(page.text, features="html.parser") elo = soup.find('p', class_="profilestyles__TierInfoLabel-y97g0w-19 jCyjuF") if elo is not None: return elo.text else: return "Unranked"
def __post_init__(self): region = config.get_region() base_url = "https://" + region + ".op.gg/summoner/userName="******" ", "")