Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from bs4 import BeautifulSoup
import requests
def obtenerContenido( id_partido ):
pagina = f"http://www.beisbolcubano.cu/estadisticas/BoxScore?idJuego={id_partido}"
peticion = requests.get(pagina)
contenido = BeautifulSoup(peticion.content, 'html.parser')
return contenido
def obtenerDataDePartido( contenido ):
data = { "inning" : [],
"equipo" : [],
"pdi" : [],
"eventos": [],
}
i = 0
for c in contenido.find_all("li", {'class' :"contenedorCalendarioInt"} ):
if i % 2 == 0:
data['pdi'].append('top')
else:
dic['pdi'].append('bottom')
i += 1
data['inning'].append( c.find("h2").text.replace("|","").replace(" Inning ","").replace("9999","9") )
data['equipo'].append( c.find("h2")['class'][0] )
# Eventos que ocurren durante el inning
for e in c.find_all("span", {'class' :"sede"} ):
data['eventos'].append(e.text)
return data
contenido = obtenerContenido(2)
data = obtenerDataDePartido(contenido)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment