Apr-26-2023, 02:04 AM
Greetings,
I am just learning to screen scrape using beautiful soup. I have been doing well so far, but thought I would make a simple script that would get the daily numbers from a lottery website and write the numbers to a file. This is a simple script but for the life of me I am unable to scrape the numbers. Below is my code, if anyone could give some suggestions on how to get the data (the date and the numbers) I would greatly appreciate it.
I am just learning to screen scrape using beautiful soup. I have been doing well so far, but thought I would make a simple script that would get the daily numbers from a lottery website and write the numbers to a file. This is a simple script but for the life of me I am unable to scrape the numbers. Below is my code, if anyone could give some suggestions on how to get the data (the date and the numbers) I would greatly appreciate it.
from bs4 import BeautifulSoup import requests url = 'https://www.palottery.state.pa.us/Draw-Games/Treasure-Hunt.aspx' response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') details_div = soup.find('div', {'class': 'details'}) balls = details_div.find_all('span', {'class': 'ball'}) for ball in balls: print(ball.text.strip())