Last active
March 21, 2018 13:29
-
-
Save kanazux/803ffc6ea759bdec23937a58758f185b to your computer and use it in GitHub Desktop.
Pega uma lista de jogos de um site que nao lembro qual, ta no codigo.
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
#!/usr/bin/python3 | |
# -*- codinf: utf-8 -*- | |
import json | |
import requests_html | |
def lista_jogos(rodada): | |
_lista_de_jogos = [] | |
for jogo in rodada.find('div.full-game'): | |
_lista_de_jogos.append( | |
{'Partida': jogo.find('div.full-game-location')[0].text.split('\n')[0], | |
'Horario': jogo.find('div.full-game-time')[0].text, | |
'Jogo': "{} x {}".format(jogo.find('div.game-team-1')[0].text, | |
jogo.find('div.game-team-2')[0].text)}) | |
return _lista_de_jogos | |
s = requests_html.HTMLSession() | |
r = s.get('https://cbf.com.br/competicoes/brasileiro-serie-a') | |
with open('jogos.json', 'w') as jogos_json: | |
jogos_json.write( | |
json.dumps(lista_jogos(r.html.find('div.rodada-1')[0]), indent=4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment