Closed Ehsan1997 closed 6 years ago
@Ehsan1997 just tested this out with the latest version of the library and didn't run into that error.
Sorry, you are right @dwillis the new version has it fixed. I thought I updated but probably missed the new version.
I was also confused about player_id and object_id, it seems to create a player object object_id is required. Also there is some problem for this id (8180).
Traceback (most recent call last):
File "C:/Users/ehsan/PycharmProjects/ScrapPSLData/CreateCSV_AdvStats.py", line 9, in <module>
p = Player(8180)
File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\site-packages\espncricinfo\player.py", line 34, in __init__
self.first_class_debut = self._first_class_debut()
File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\site-packages\espncricinfo\player.py", line 173, in _first_class_debut
url = 'http://www.espncricinfo.com'+first_class_debut.find('a')['href']
TypeError: 'NoneType' object is not subscriptable
There is probably no 'a' tag in first_class_debut.
Good catch. object_id
is what the cricinfo match JSON calls the player_id, so we need to use that in places. The debuts code is probably not long for this world because there is a way to get that that doesn't rely on HTML parsing, instead using more JSON. But in the meantime I'll handle this error.
Just pushed a fix for https://github.com/dwillis/python-espncricinfo/issues/24#issuecomment-410534291
Here's the traceback, as you can see the problem arises when trying to get player data with id '10125'. Probably some unhandled exception.