[Python] How can I fix my Python scraper for UK49s lottery results? (HTML parsing issue)

Discussão em 'Python' iniciado por Stack, Junho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to scrape UK49s Lunchtime lottery results from this page:

    https://uk49s.net/
    I wrote a simple Python scraper using requests and BeautifulSoup, but I'm not getting the correct results. I want to extract the 6 main numbers and the bonus ball from the Lunchtime draw.

    import requests
    from bs4 import BeautifulSoup

    url = "https://uk49s.net/"
    response = requests.get(url)

    soup = BeautifulSoup(response.text, 'lxml')

    # Trying to get Lunchtime result numbers
    lunchtime_section = soup.find("div", class_="results") # Not sure if this is the correct class
    numbers = lunchtime_section.find_all("span", class_="ball ball") # Is this correct?

    for num in numbers:
    print(num.text)


    Please let me know how to fix it.
    Thanks

    I tried using Python with requests and BeautifulSoup to scrape the UK49s Lunchtime results from the official results page. I expected the code to print the 6 main numbers and the bonus ball from the Lunchtime draw, but nothing is printed. Sometimes I also get an AttributeError, so I think the HTML class or structure might not be matching what I wrote in the code.

    Continue reading...

Compartilhe esta Página