I am trying to scrap for betting odds and the fixture names from the website betting explorer whose full address is https://www.betexplorer.com, I have tried to use this script to do it but it os saying that no table was found, please help me make it work
import pandas as pd
import requests
from bs4 import BeautifulSoup
# DEFINE THE URL to use for mining odds
URL = "https://www.betexplorer.com/"
# Send a GET request to the URL
response = requests.get(URL)
# Check if the request was successful
if response.status_code == 200:
# Parse the HTML content
soup = BeautifulSoup(response.text, 'html.parser')
# Find the table with the soccer odds
table_matches = soup.find('table', attrs={'class': 'table-main-js-tablebanner-t js-tablebanner-ntb'})
if table_matches:
data = []
rows = table_matches.find_all('tr')
for row in rows:
utils = []
cols = row.find_all('td')
for element in cols:
# Clean up the text and add it to the utils list
utils.append(element.get_text(strip=True))
if utils: # Only append non-empty rows
data.append(utils)
# Create a DataFrame with the scraped data
df = pd.DataFrame(data, columns=["Match", "Result", "1", "X", "2", "Date"])
print(df)
else:
print("No table found on the page.")
else:
print(f"Failed to retrieve data. HTTP Status code: {response.status_code}")
I expected the code to generate a Pandas Data Frame that will have the match name, odd for the home team, odd for a draw, odd for the away side to win and the date time the event is supposed to happen, because the websites uses a table to represent the fixture details, help me make it work.