Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New player endpoint for major_teams #62

Merged
merged 7 commits into from
Jan 13, 2024

Conversation

JackMa222
Copy link
Contributor

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:

def _major_teams(self):
        return [x.text for x in self.parsed_html.find('div', class_='overview-teams-grid').find_all('h5')]

There is a new endpoint which the ESPN Cricinfo page appears to utilise for player data (or in conjunction with the previous). Example: (https://hs-consumer-api.espncricinfo.com/v1/pages/player/home?playerId=7069)

This provides similar data to the previous endpoint, however there are some differences. For this reason I have only modified the major_teams function with this in order to get it functional (with which the rest are).

def _major_teams(self):
        return [x['team']['longName'] for x in self.new_json['content']['teams']]

Eventually it would most likely be wise to update the rest of the functions to the latest 'endpoint' but for now this fixes previous problems.

… players with expansive careers this often takes many seconds as it has to visit each team page individually. Also added new exception in exceptions.py to deal with a 404 HTTP error.
…nfo webpage) to get major teams swiftly. Introduced new json link and function to allow for this
@dwillis dwillis merged commit 80878bb into outside-edge:master Jan 13, 2024
2 checks passed
@dwillis
Copy link
Collaborator

dwillis commented Jan 13, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants