Skip to content

Instantly share code, notes, and snippets.

@kanazux
Last active March 21, 2018 13:29
Show Gist options
  • Save kanazux/803ffc6ea759bdec23937a58758f185b to your computer and use it in GitHub Desktop.
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.
#!/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