roclark / sportsipy

A free sports API written for python
MIT License
475 stars 189 forks source link

NFL Boxscore: lxml b'Tag use invalid' #739

Open RichardSJTotten opened 2 years ago

RichardSJTotten commented 2 years ago

Describe the bug When attempting to use Boxscore function, I get an error reading: File "src/lxml/etree.pyx", line 3252, in lxml.etree.fromstring File "src/lxml/parser.pxi", line 1913, in lxml.etree._parseMemoryDocument File "src/lxml/parser.pxi", line 1793, in lxml.etree._parseDoc File "src/lxml/parser.pxi", line 1082, in lxml.etree._BaseParser._parseUnicodeDoc File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult File "src/lxml/parser.pxi", line 663, in lxml.etree._raiseParseError File "", line 3665 lxml.etree.XMLSyntaxError: line 3665: b'Tag use invalid'

To Reproduce from sportsipy.nfl.boxscore import Boxscores, Boxscore

game_str = Boxscores(1,2021).games['1-2021'][0]['boxscore'] game_stats = Boxscore(game_str)

Expected behavior I was expecting the game stats to be returned in JSON format which I could then turn into a dataframe.

Desktop (please complete the following information):

westaa commented 1 year ago

I'm getting the same, Richard. I am trying to seed my NFL database in time for the season start. Sportsipy is an awesome API, and I would love to get this fixed soon.

from sportsipy.nfl.boxscore import Boxscore

game_data = Boxscore("202012070sfo")
print(game_data)

// lxml.etree.XMLSyntaxError: line 3608: b'Tag use invalid'

RichardSJTotten commented 1 year ago

Hey @westaa -> I received a fix in a separate issue:

First clone the repo to your local machine and then apply the fix below in the local repo and it should work. I had to pip uninstall the package for it to work correctly.

CodeeMcCoderson commented 10 days ago @RichardSJTotten to fix the problem that I had, which seems almost identical to yours, is I changed the sportsipy module directly on my hard drive. I did not pull down the fix that I posted earlier.

If you navigate to where you have your modules stored on your local machine, find the 'sportsipy' module and got into it. Then go into the 'nfl' module and click on the 'constants.py' scripts.

Within that script navigate to line 81 and change this line of code: 'home_name': 'a[itemprop="name"]:first', To this: 'home_name': 'div[class="linescore_wrap"] table tbody tr:last td:nth-child(2)',

Next go to line 84 and change this line of code: 'away_name': 'a[itemprop="name"]:last', To this: 'away_name': 'div[class="linescore_wrap"] table tbody tr:first td:nth-child(2)',

After changing it, save the script, navigate to your script that was throwing the error and run it again. It should work.

Let me know if anything was not clear or if it does not work, I will try and help more.

westaa commented 1 year ago

Sorry for the late reply. Thank you so much for posting this, @RichardSJTotten. I will try this today.

reaganking commented 1 year ago

The above fix initially worked, but now I'm getting a similar issue:

lxml.etree.XMLSyntaxError: line 1636: b'Tag use invalid'

ericmk52 commented 1 year ago

@RichardSJTotten

The fix appears to work for all seasons prior to the current 2022 season.

kaulfuss commented 1 year ago

@RichardSJTotten

The fix appears to work for all seasons prior to the current 2022 season.

I'm finding the same to be true. I've applied the fix, uninstalled and reinstalled, etc. Any ideas? Thanks!