Example #1
0
 def get_data(self):
     self.driver = spawn_driver() if not self.driver else self.driver
     sb = self.get_old_sidebar()
     fixtures = self.fixtures()
     results, last_result, last_opponent = self.results()
     match_threads = self.get_match_threads(last_opponent)
     return sb, fixtures, results, last_result, match_threads
Example #2
0
File: mtb.py Project: Nexamic/yeet
    def _test(self):
        driver = spawn_driver()
        print("Driver spawned.")

        # Finished: https://www.flashscore.com/match/EyG1EdgD (NEW - ARS)
        # Upcoming: https://www.flashscore.com/match/lGuaXAah (NEW - PAL)

        driver.get("https://www.flashscore.com/match/EyG1EdgD")
        print('Got page.')
        referee = ""
        venue = ""
        try:
            # Get venue / competition / referee.
            xp = (By.XPATH, ".//div[@class='match-information-data']")
            x = WebDriverWait(driver,
                              3).until(ec.presence_of_element_located(xp))

            tree = html.fromstring(driver.page_source)
            match_info = tree.xpath(
                f".//div[@class='match-information-data']//text()")
            competition = "".join(
                tree.xpath(".//span[@class='description__country']//text()"))
            complink = "".join(
                tree.xpath(
                    ".//span[@class='description__country']//a/@onclick"))
            print(f"complink: {complink}")
            try:
                complink = complink.split('\'')[1]
                complink = f"http://www.flashscore.com{complink}"
            except IndexError:
                complink = ""

            self.data[
                'competition'] = f"[{competition}]({complink})" if complink else competition
            for i in match_info:
                i = i.replace(',\xa0', '')
                if i.startswith('Referee'):
                    self.data['referee'] = i.split(': ')[-1].split('(')[0]
                if i.startswith('Venue'):
                    self.data['venue'] = i.split(': ')[-1].split('(')[0]
        except Exception as e:
            print(e)

        # Get H2H data
        ## H2h data at all venues
        ## H2H data at Home venue

        # Get form data
        ## Last 5 games each
        ## Last 5 home games home
        ## Last 5 away games away

        # Get Current table

        # Get Injury & Suspension data

        driver.quit()
        print("Driver closed.")
        return
Example #3
0
 def __init__(self, bot):
     self.bot = bot
     try:
         self.driver = self.bot.fixture_driver
     except AttributeError:
         self.bot.fixture_driver = spawn_driver()
         self.driver = self.bot.fixture_driver
     for package in [transfer_tools, football, embed_utils]:
         reload(package)
Example #4
0
    def __init__(self, bot):
        self.bot = bot
        if self.bot.score_driver is None:
            self.bot.score_driver = spawn_driver()

        # Reload utils
        for i in [football, embed_utils]:
            reload(i)
        # Data
        if not hasattr(self.bot, "games"):
            self.bot.games = []
        self.game_cache = {}  # for fast refresh
        self.msg_dict = {}
        self.cache = defaultdict(set)
        self.bot.loop.create_task(self.update_cache())

        # Core loop.
        self.bot.scores = self.score_loop.start()
Example #5
0
 def __init__(self, bot):
     self.bot = bot
     if self.bot.fixture_driver is None:
         self.bot.fixture_driver = spawn_driver()
     for package in [transfer_tools, football, embed_utils]:
         reload(package)