def get_table(self, driver) -> BytesIO: clicks = [(By.XPATH, ".//span[@class='button cookie-law-accept']")] xp = './/div[contains(@class, "tableWrapper")]' image = selenium_driver.get_image(driver, self.url + "#standings;table;overall", xp, delete=FLASH_SCORE_ADS, clicks=clicks, failure_message="No table found for this league.") return image
def get_table(self, driver) -> BytesIO: xp = './/div[contains(@class, "tableWrapper")]/parent::div' table_page = self.link + "/standings/" err = f"No table found on {table_page}" image = selenium_driver.get_image(driver, table_page, xp, failure_message=err, delete=FLASH_SCORE_ADS) self.fetch_logo(driver) return image
def bracket(self, driver) -> BytesIO: xp = './/div[@class="overview"]' clicks = [(By.XPATH, ".//span[@class='button cookie-law-accept']")] script = "var element = document.getElementsByClassName('overview')[0];" \ "element.style.position = 'fixed';element.style.backgroundColor = '#ddd';" \ "element.style.zIndex = '999';" image = selenium_driver.get_image(driver, self.url + "#draw", xpath=xp, clicks=clicks, delete=FLASH_SCORE_ADS, script=script, failure_message="Unable to find bracket for that tournament.") return image
def formation(self, driver) -> BytesIO: delete = [(By.XPATH, './/div[@id="lsid-window-mask"]')] xp = './/div[@id="lineups-content"]' image = selenium_driver.get_image( driver, self.url + "#lineups;1", xp, delete=delete, failure_message="Unable to find formations for this match") return image
def stats_image(self, driver) -> BytesIO: delete = [(By.XPATH, './/div[@id="lsid-window-mask"]')] xp = ".//div[@class='statBox']" image = selenium_driver.get_image( driver, self.url + "#match-statistics;0", xp, delete=delete, failure_message="Unable to find live stats for this match.") return image
def summary(self, driver) -> BytesIO: delete = [(By.XPATH, './/div[@id="lsid-window-mask"]')] xp = ".//div[@id='summary-content']" image = selenium_driver.get_image( driver, self.url + "#match-summary", xp, delete=delete, failure_message="Unable to find summary for this match") return image
def bracket(self, driver) -> BytesIO: url = self.link + "/draw/" xp = './/div[@id="box-table-type--1"]' multi = (By.PARTIAL_LINK_TEXT, 'scroll right »') clicks = [(By.XPATH, ".//span[@class='button cookie-law-accept']")] script = "document.getElementsByClassName('playoff-scroll-button')[0].style.display = 'none';" \ "document.getElementsByClassName('playoff-scroll-button')[1].style.display = 'none';" captures = selenium_driver.get_image(driver, url, xpath=xp, clicks=clicks, delete=FLASH_SCORE_ADS, multi_capture=(multi, script), failure_message="Unable to find a bracket for that competition") self.fetch_logo(driver) # For base_embed. return image_utils.stitch(captures)
def table(self, driver): delete = [(By.XPATH, './/div[@class="seoAdWrapper"]'), (By.XPATH, './/div[@class="banner--sticky"]'), (By.XPATH, './/div[@class="box_over_content"]')] err = "No table found for this league." xp = './/div[@class="table__wrapper"]' image = selenium_driver.get_image(driver, self.url + "#standings;table;overall", xp, delete=delete, failure_message=err) return image
def table(self, driver) -> BytesIO: xp = './/div[@class="table__wrapper"]' clicks = [(By.XPATH, ".//span[@class='button cookie-law-accept']")] delete = [(By.XPATH, './/div[@class="seoAdWrapper"]'), (By.XPATH, './/div[@class="banner--sticky"]'), (By.XPATH, './/div[@class="box_over_content"]')] err = f"No table found on {self.link}" image = selenium_driver.get_image(driver, self.link + "/standings/", xp, err, clicks=clicks, delete=delete) self.fetch_logo(driver) return image
def bracket(self, driver): xp = './/div[@class="overview"]' clicks = [(By.XPATH, ".//span[@class='button cookie-law-accept']")] delete = [(By.XPATH, './/div[@class="seoAdWrapper"]'), (By.XPATH, './/div[@class="banner--sticky"]'), (By.XPATH, './/div[@class="adsenvelope"]'), (By.XPATH, './/div[contains(@class, "rollbar")]')] script = "var element = document.getElementsByClassName('overview')[0];" \ "element.style.position = 'fixed';element.style.backgroundColor = '#ddd';" \ "element.style.zIndex = '999';" image = selenium_driver.get_image( driver, self.url + "#draw", xpath=xp, clicks=clicks, delete=delete, script=script, failure_message="Unable to find a bracket for that competition") return image
def summary(self, driver) -> BytesIO: xp = ".//div[@id='summary-content']" image = selenium_driver.get_image(driver, self.url + "#match-summary", xp, delete=FLASH_SCORE_ADS, failure_message="Unable to find summary for this match") return image
def get_formation(self, driver) -> BytesIO: clicks = [(By.XPATH, './/div[@id="onetrust-accept-btn-handler"]')] xp = './/div[@id="lineups-content"]' image = selenium_driver.get_image(driver, self.url + "#lineups;1", xp, delete=FLASH_SCORE_ADS, clicks=clicks, failure_message="Unable to find formations for this match") return image
def stats_image(self, driver) -> BytesIO: xp = ".//div[@class='statBFox']" image = selenium_driver.get_image(driver, self.url + "#match-statistics;0", xp, delete=FLASH_SCORE_ADS, failure_message="Unable to find live stats for this match.") return image
def get_badge(self, driver, team) -> BytesIO: xp = f'.//div[contains(@class, tlogo-{team})]//img' badge = selenium_driver.get_image(driver, self.url, xpath=xp, failure_message="Badge not found.") return badge