Skip to content

Conversation

@dimitrismoustakas
Copy link

As discussed on Issues #904 and #905, the understat module has stopped working. Understat no longer supports HTML scraping but instead offers API endpoints where you can access the same data as before. I've made the change so that the package uses the endpoints instead. Understat tests pass (they don't pass on the current main branch), but not tests on the other packages. I've tested and these tests failed to begin with so it's not an issue my pull causes but there's an underlying issue with these modules or the tests are not maintained properly.

API Integration and Data Fetching Improvements:

  • Refactored league, season, and match data retrieval to use Understat's internal API endpoints (/getStatData, /getLeagueData/{league}/{season}, /getMatchData/{match_id}) instead of HTML scraping.
  • Added the _request_api helper method to centralize API requests with appropriate headers, caching, and file storage, improving consistency and reducing code duplication.
  • Introduced the UNDERSTAT_HEADERS constant to ensure all API requests include the required X-Requested-With header.

Session and Cookie Management:

  • Added _ensure_cookies to initialize session cookies from the homepage before making API requests, ensuring authenticated and consistent access. [1] [2]

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.

1 participant