Last active
July 2, 2024 10:56
-
-
Save luxu/a37eadb4162b1dd1ad99940032c91c2e to your computer and use it in GitHub Desktop.
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 time import sleep | |
from requests import get | |
from parsel import Selector | |
from datetime import datetime as dt | |
rodadas_ids = [ | |
"D4sWXlbMU0OyN9WzJhZ6Z", | |
"PwIBz94Zca1ZZV6Db-i7E", | |
"BXCCzR007HOYgC_KjXpRt", | |
"atuoTau-ep2Rq0K3lCNUE", | |
"9LxWw3C41mx15vMadpYEZ", | |
"OCGZuvPELb4cIevVwCx8o", | |
"vEyrR-38AxI53k4AQXo9z", | |
"6irWC4BBfJJl7UlQStYg2", | |
"ebg0TMDlsHZcXWtgq9n0F", | |
"lzNWMQCIkfdlNaDUzU9q9", | |
"X2G0UUeqIfmBM7HnshCss", | |
"Bvp7no9EJZddDYD1VGs2U", | |
"DwtbogV1TPYMGcu17BRHw", | |
"N8TXEIB3wax8iDxYJN9yl", | |
"tY1Fimb3J2LHyuPbkELye", | |
"4ifL5-A1h5XBtn_XENiA4", | |
"edNvo0Eu1e6FL7gx2yJC9", | |
"SxYxhnU81-DKbwsdrISA3", | |
"6p_BMLR5bjncG83w6D16-", | |
"VZUR1MmKkTC-PQU3ccph1", | |
"ngJiYZSZIwdEuaYek6XUZ", | |
"iRH3JEoR_GdskctLkRAp0", | |
"CISS-q5f_ImG2tEW88bcj", | |
"DhyGyKaVTOyjWkEvDcSJq", | |
"lEB4KiDa2okJBTsxLF3CC", | |
"Uer2Reol2Rk3DSo_QnyII", | |
"Jh-iORkBEgIwOL4XCU5p7", | |
"sz1DD_x-2ZbgVFQOg_lJ2", | |
"ONeHsXtU_D8GVPpkinK63", | |
"lfskzRsT-l9aJkoAxV2HM", | |
"_gTI7jyzSXCw3k3XMO2Iw", | |
"JCZ39xoy_XYSLOed0TZgg", | |
"4IKNBK6J1be6GEYp1YRel", | |
"WzwWECNQHxp8TzjUqYCgG", | |
"hLNx3KHbX2xrFAXEb4dxe", | |
"VGllthXE_Jor1VdI2yF7A", | |
"Cr0MBV0K0Aontus4_CcrG", | |
"LmpZiDKCr6pGFJT_Z-y50" | |
] | |
data_de_hoje = dt.today() | |
for rodada in rodadas_ids: | |
url = f'https://www.goal.com/api/competition-matches?edition=br&id=scf9p4y91yjvqvg5jndxzhxj&country=BR&gameSetTypeIds={rodada}' | |
r = get(url) | |
selector = Selector(r.text) | |
matches = selector.get()['gamesets'][0]['matches'] | |
rodada_numero = selector.get()['gamesets'][0]['name'] | |
print(f'{rodada_numero}') | |
rodadas_futuras = 0 | |
for match in matches: | |
sleep(1) | |
teamA = match['teamA']['name'] | |
teamB = match['teamB']['name'] | |
data_html = match['startDate'] | |
data_do_jogo = dt.strptime(data_html, '%Y-%m-%dT%H:%M:%S.%fZ') | |
if data_do_jogo >= data_de_hoje: | |
rodadas_futuras += 1 | |
data_do_jogo.strftime('%d/%m/%Y') | |
try: | |
score_team_a = match['score']['teamA'] | |
score_team_b = match['score']['teamB'] | |
except TypeError as err: | |
score_team_a = '' | |
score_team_b = '' | |
print(f'Data..:{data_do_jogo} - {teamA} {score_team_a} X {score_team_b} {teamB}') | |
if rodadas_futuras > 1: | |
print('Rodadas Futuras!!') | |
break | |
print(f'Fim da rodada..:{rodada_numero}\n{"="*50}\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment