Created
June 25, 2018 20:35
-
-
Save trinaldi/b02b64d474454a34bd73ee5abd9d49fd to your computer and use it in GitHub Desktop.
Bolão Tios do Peidinho
This file contains hidden or 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
#!/usr/bin/env python | |
from colorama import Fore, Style | |
import requests, bs4, sys | |
try: | |
r = requests.get('http://www.maisbolao.com.br/bolao/classificacao/35614/grande-bolao-tios-do-peidinho-014-e-nois', timeout=30) | |
except: | |
print("Tentei por 30 segundos e nada...") | |
sys.exit(1) | |
soup = bs4.BeautifulSoup(r.text, 'lxml') | |
table = soup.find("table", "table table-striped classificacao") | |
if len(table) > 0: | |
rows = table.findAll("td", ["nome", "total", "ap", "gv", "sg", "gp", "av", "eg"]) | |
else: | |
print("Não consegui pegar dados...") | |
sys.exit(1) | |
header = ["Nome", "Total", "AP", "GV", "SG", "GP", "AV", "EG"] | |
print(f'{Fore.GREEN}', end="") | |
for i,h in enumerate(header): | |
if i == 0: | |
print(h, end="".ljust(21)) | |
else: | |
print(h, end="".rjust(8)) | |
lst = [] | |
print("") | |
print(f'{Style.RESET_ALL}', end="") | |
print("-"*95) | |
for row in rows: | |
lst.append(row.getText().rjust(10)) if row.getText().isdigit() else \ | |
lst.append(row.getText().ljust(20)) | |
placar = "\n".join([''.join(i) for i in zip(*[iter(lst)]*8)]) | |
print(placar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment