Skip to content

Instantly share code, notes, and snippets.

@guiszk
Created March 20, 2022 13:31
Show Gist options
  • Save guiszk/a5db89531b3126a0612795edf25c0cfc to your computer and use it in GitHub Desktop.
Save guiszk/a5db89531b3126a0612795edf25c0cfc to your computer and use it in GitHub Desktop.
CLI program to get Brazilian Mega-Sena results.
from bs4 import BeautifulSoup as bs
from urllib.request import urlopen
url = "https://resultado-megasena.com"
content = urlopen(url).read()
soup = bs(content, 'html.parser')
for i in soup.findAll('p', {'class': 'text'}):
for j in i.text.split('\n'):
if('Estes são os números ganhadores do sorteio' in j):
line = j.split(' ')
day = line[15]
num = line[19]
res = ' '.join(line[20:])[:-2]
print(f"{day} #{num} {res}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment