niesfutbol / ideas

0 stars 0 forks source link

Match url and id from round #89

Closed nepito closed 3 weeks ago

nepito commented 1 month ago

Referencias

nepito commented 1 month ago

Parece que solo tendremos datos de momentum para las temporadas 2022-23 y 2023-24.

nepito commented 1 month ago
import requests
import sofa_score_data as ssd

league_url: str = "https://www.fotmob.com/api/leagues?id=55&ccode3=MEX&season=2022%2F2023"
r = requests.get(league_url)
league_info = r.json()
match_id: list = ssd.get_matches_id(league_info)
last_five_matches = [
    requests.get(f"https://www.fotmob.com/api/matchDetails?matchId={id_m}").json()
    for id_m in match_id[-5:]
]
xG = [shot["expectedGoals"] for shot in ssd.get_all_shots(last_five_matches[3])]
nepito commented 1 month ago

id of different leagues

nepito commented 1 month ago
from pydantic import BaseModel

class Person(BaseModel):
    name: str
    times: int

param = {"name": "Nepo", "times": 3, "otro": [1,2,3,4]}

p_1 = Person(**param)

def saluda(personita: Person) -> None:
    for i in range(personita.times):
        print(personita.name)

saluda(p_1)
nepito commented 1 month ago
expectedGoalsOnTarget = [
    shot["expectedGoalsOnTarget"]
    for shot in ssd.get_all_shots(last_five_matches[0])
    if ((shot["teamId"] == 9857) & (shot["expectedGoalsOnTarget"] is not None))
]
expectedGoals = [
    shot["expectedGoals"]
    for shot in ssd.get_all_shots(last_five_matches[0])
    if shot["teamId"] != 9857
]
nepito commented 3 weeks ago

Agregamos:

Con esto ya podemos tener los resultados de los partidos, el porcentaje del momentum y todos los tiros de la temporada.