Example #1
0
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)
Example #2
0
 def weapon(self):
     try:
         r = _request(f"{self.base_url}{self.name}.json", call="json")
         print(r)
         return r[0]
     except IndexError:
         return r
Example #3
0
 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")
Example #4
0
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)
Example #5
0
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)
Example #6
0
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()