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

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

Open
RichardSJTotten opened this issue Jul 14, 2022 · 6 comments
Open

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

RichardSJTotten opened this issue Jul 14, 2022 · 6 comments

Comments

@RichardSJTotten
Copy link

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):

  • OS: macOS Monterey
  • Sportsipy Version: 0.6.0
@RichardSJTotten RichardSJTotten changed the title Boxscore: lxml b'Tag use invalid' NFL Boxscore: lxml b'Tag use invalid' Jul 14, 2022
@westaa
Copy link

westaa commented Jul 24, 2022

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
Copy link
Author

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
Copy link

westaa commented Jul 30, 2022

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

@reaganking
Copy link

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

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

@ericmk52
Copy link

@RichardSJTotten

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

@kaulfuss
Copy link

@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!

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

No branches or pull requests

5 participants