def get_match_history(player, platform): mh_url = f"https://public-api.tracker.gg/v2/apex/standard/profile/{platform_convert(platform)}/{player}/sessions" try: r = _request(mh_url, headers=headers, call="json") return r["data"] except Exception as e: raise PlayerNotFound(e)
def weapon(self): try: r = _request(f"{self.base_url}{self.name}.json", call="json") print(r) return r[0] except IndexError: return r
def data(self) -> dict: """Returns player's data""" URL = f"https://public-api.tracker.gg/v2/apex/standard/profile/{self.platform}/{self.player}" try: r = _request(URL, headers=headers, call="json") return r["data"] except Exception: raise PlayerNotFound("Request failed")
def get_news(limit=6) -> str: """Get news from https://www.ea.com/games/apex-legends/news""" news_url = "https://www.ea.com/games/apex-legends/news" content = _request(news_url, headers=user_agent, call="text") page = BeautifulSoup(content, features="lxml") news_link = [] acc = 1 for c in page.find_all("a", href=True): if str(c['href']).startswith( '/games/apex-legends/news/') and len(news_link) < limit: news_link.append('**#{}** {}{}'.format(acc, "https://www.ea.com", c['href'])) acc += 1 return '\n\n'.join(news_link)
def get_post(categorie) -> str: """Returns reddit url filtered by categorie -> returns urls filtered""" url = f"{reddit}/r/apexlegends/{categorie}" content = _request(url, headers=user_agent, call="text") page = BeautifulSoup(content, features="lxml") reddit_post, check_list = [], [] for a in page.find_all('a', href=True): if a['href'].startswith( '/r/apexlegends/comments/' ) and reddit + a['href'] not in check_list and checkDaily(a['href']): check_list.append(reddit + a['href']) reddit_post.append('[r/apexlegends/{}]({})\n'.format( get_subj_title(a['href']), reddit + a['href'])) return '\n'.join(reddit_post)
def get_server_status(): content = _request(SERVERS, cookies={'lang': 'EN'}, call="text") page = BeautifulSoup(content, features="lxml") status = page.find(class_="alert") return status.get_text()