Python Forum
Simple screen scrape is baffling me.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple screen scrape is baffling me.
#1
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.


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())
Reply


Messages In This Thread
Simple screen scrape is baffling me. - by monty024 - Apr-26-2023, 02:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  scrape data 1 go to next page scrape data 2 and so on alkaline3 6 5,295 Mar-13-2020, 07:59 PM
Last Post: alkaline3

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020