NBA-Search
NBA-Search copied to clipboard
test_get_adv_stats is failing from NoneType object
Describe the bug
test_get_adv_stats is failing, seems to be from a missing div when scraping advanced stats.
To Reproduce Steps to reproduce the behavior:
- Setup the environment with
./setup.sh - Run
python main.py testto run unit tests - See error
ERROR: test_get_adv_stats (tests.module_tests.TestScraper)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/circleci/project/tests/module_tests.py", line 107, in test_get_adv_stats
stat = scraper.get_adv_stat(random_name, random_stat)
File "/home/circleci/project/modules/scraper.py", line 288, in get_adv_stat
comments = advanced_div.find_all(string=lambda text: isinstance(text, Comment))[0]
AttributeError: 'NoneType' object has no attribute 'find_all'
Expected behavior This should correctly scrape the advanced of NBA players and check for any NoneType objects in case there is an error in scraping or something is removed in the future.
Desktop (please complete the following information):
- OS: n/a
- Browser: n/a
- Version: n/a
Additional context This is setup agnostic the issue was found during CircleCI tests.
You can assign this issue to me. I'll review it in the next couple of days.
Awesome, thanks @AColocho
@skekre98 I found the issue. Basketball Reference removed the comment that was used as an anchor to find the table. I'm having trouble understand what the function returns. Is it just the latest stat as a float? or is it all the available stats for the category as a list of floats?
Hi @AColocho, the function should be returning the advanced statistic as a float value. The user will specify the name of the player and the advanced statistic to retrieve when calling the function. For example:
stat = scraper.get_adv_stat("Kobe Bryant", "defensive box plus/minus")
is this issue done or not, i would like to do on it
Issue is done. It's waiting code review and merge.