Closed JackMa222 closed 8 months ago
Appears to be a better way (as always) - currently working on. Team info appears inside the json at the bottom of the HTML inside the script <script id="__NEXT_DATA__" type="application/json">
. How we access this via API endpoints I am unsure at the moment.
I will close this request and open a new PR with a rewrite of the player class.
Player Object Update - Major Teams (_major_teams)
This attempts to fix issue [BUG] Player class is not working with Python 3.11.0 #59
The ESPN CricInfo html page has been updated with class and syntax changes which mean the previous _major_teams function did not work:
The JSON for each player provides a list of their teams through links with links like http://core.espnuk.org/v2/sports/cricket/teams/2
I have written an updated function that visits gets each of these json files, gets the team name and appends the names to a list which is then returned
I also wrote a new error in exceptions.py to handle the 404 HTTP errors - TeamNotFoundError
Time consideration
Unfortunately, due to the manner in which this function individually requests each team page, the function is considerably slower the before. Further players with a large amount of teams, eg. Steve Smith take up ~16 seconds. This seriosuly affects the usage of the function. For this reason there may be another way to get the major teams, for example seperate this function from the rest.