This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from selenium import webdriver | |
| from selenium.webdriver.common.by import By | |
| from selenium.webdriver.support.ui import WebDriverWait | |
| from selenium.webdriver.support import expected_conditions as EC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| web = 'https://sports.tipico.de/en/all/football/spain/la-liga' #you can choose any other league | |
| path = '/Users/Downloads/chromedriver' #introduce your file's path inside '...' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| teams = [] | |
| x12 = [] #3-way | |
| odds_events = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| time.sleep(5) #add implicit wait, if necessary | |
| accept = driver.find_element_by_xpath('//*[@id="_evidon-accept-button"]') | |
| accept.click() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for sport in sport_title: | |
| # selecting only football | |
| if sport.text == 'Football': | |
| parent = sport.find_element_by_xpath('./..') | |
| grandparent = parent.find_element_by_xpath('./..') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| empty_groups = grandparent.find_elements_by_class_name('EventOddGroup-styles-empty-group') | |
| empty_event = [empty_group.find_element_by_xpath('./..') for empty_group in empty_groups[:]] | |
| except: | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| single_row_events = grandparent.find_elements_by_class_name('EventRow-styles-event-row') | |
| #remove empty groups | |
| try: | |
| for event in empty_event: | |
| if event in single_row_events: | |
| single_row_events.remove(event) | |
| except: | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for match in single_row_events: | |
| # teams | |
| for team in match.find_elements_by_class_name('EventTeams-styles-titles'): | |
| teams.append(team.text) | |
| # scores | |
| for score in match.find_elements_by_class_name('EventScores-styles-scores'): | |
| scores.append(score.text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| odds_events = [match.find_elements_by_class_name('EventOddGroup-styles-odd-groups') for match in single_row_events] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| driver = webdriver.Chrome(path) | |
| driver.get(web) |
OlderNewer