Created
March 20, 2022 13:31
-
-
Save guiszk/a5db89531b3126a0612795edf25c0cfc to your computer and use it in GitHub Desktop.
CLI program to get Brazilian Mega-Sena results.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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