From a betting site, I want to collect the betting rates. After inspecting the page, I noticed that these rates were included into a eventprice class. Following the explanation from here, I thus wrote this code in Python, using Beautifulsoup module:
from bs4 import BeautifulSoup
import urllib.request
import re
url = "http://sports.williamhill.com/bet/fr-fr"
try:
page = urllib.request.urlopen(url)
except:
print("An error occured.")
soup = BeautifulSoup(page, 'html.parser')
regex = re.compile('eventprice')
content_lis = soup.find_all('button', attrs={'class': regex})
print(content_lis)
However, I got the following error:
"(...) line 12, in soup = BeautifulSoup(page, 'html.parser') NameError: name 'page' is not defined"
try
won’t be successful, thanpage
won’t be defined. – MendelG