Aug-18-2021, 04:19 PM
Excuse me, but i have again a question. I am trying for at least 10 hours to scrape the data from betmonitor, but everytime when i think i've got a good python script, it doesn't work .
With the code below, i try to get a Excel file with 5 columns: date, league, match, 1x2odd (3 seperatie columns) and ouodd (2 seperate columns).
Can somebody please tell me what is wrong in the code below and why i don't get any data?
Thanks a lot!!!!
With the code below, i try to get a Excel file with 5 columns: date, league, match, 1x2odd (3 seperatie columns) and ouodd (2 seperate columns).
Can somebody please tell me what is wrong in the code below and why i don't get any data?
Thanks a lot!!!!
from selenium import webdriver import time import pandas as pd url = 'https://www.betmonitor.com/odds-comparison/football/germany-bundesliga/10000090' driver = webdriver.Chrome(executable_path='C:/webdrivers/chromedriver.exe') evt_details = [] driver.get(url) time.sleep(5) evt_list = driver.find_elements_by_css_selector('div.league-event-new') for evt_match in evt_list: # Getting match info evt_date = evt_match.find_elements_by_xpath('//div[@class="evtime"]')[0] evt_league = evt_match.find_elements_by_xpath('//div[@class="league"]')[0] evt_teams = evt_match.find_elements_by_xpath('//div[@class="teams"]')[0] for x in range(1, 20) evt_1x2odds = evt_match.find_elements_by_xpath('//*[@id="content"]/div[{x}]/div[4]"]')[0] evt_OUodds = evt_match.find_elements_by_xpath('//*[@id="content"]/div[{x}]/div[5]"]')[0] # Saving match info match_info = [evt_date.text, evt_league.text, evt_teams.text, evt_1x2odds.text, evt_OUodds.text] # Saving into evt details evt_details.append(match_info) driver.quit() evt_details_df = pd.DataFrame(evt_details) evt_details_df.columns = ['date', 'league', 'teams', 'odds 1x2', 'odds OU2.5'] evt_details_df.to_csv('evt_details.csv', index=False)