j-andrews7 / kenpompy

A simple yet comprehensive web scraper for kenpom.com.
https://kenpompy.readthedocs.io/en/latest/?badge=latest
GNU General Public License v3.0
73 stars 21 forks source link

summary.get_teamstats() doesn't work as intended when season parameter is not provided, but defense=True #12

Closed esqew closed 2 years ago

esqew commented 2 years ago

A small typo in summary.py builds the URL just slightly incorrectly, which causes a 404 Not Found to be returned by the server when the HTTP request is executed. This logic seems it would only hit when calling kenpompy.summary.get_teamstats() without providing a value for the season parameter, but explicitly specifying defense=True.

(I'll be submitting a PR momentarily to fix this.)

Reproduction

Code

import kenpompy.utils as kp
import kenpompy.summary as kp_s

browser = kp.login('valid_email@provider.domain', 'valid_password')
summary = kp_s.get_teamstats(browser, defense=True)

Expected behavior

The code retrieves the page containing the defensive team statistics and parses it into a DataFrame object.

Actual behavior

The code attempts to find the relevant table element in the DOM, but is unsuccessful (since the table doesn't exist in the 404 document) and throws IndexError: list index out of range at summary.py:155.

j-andrews7 commented 2 years ago

Pretty sure this is the same as #7, which I thought I had fixed but apparently not. I'll take a look when I get a chance, thanks for the PR.

esqew commented 2 years ago

My pleasure -thanks for the great library!