oseymour / ScraperFC

Python package for scraping soccer data from a variety of sources
GNU General Public License v3.0
222 stars 49 forks source link

Sofascore Scraping issue #43

Closed rayml11 closed 2 days ago

rayml11 commented 3 months ago

Question:

i was trying to pull the player stats of a whole season of sofascore and it gave me this error.

JSONDecodeError Traceback (most recent call last)

/usr/local/lib/python3.10/dist-packages/requests/models.py in json(self, kwargs) 970 try: --> 971 return complexjson.loads(self.text, kwargs) 972 except JSONDecodeError as e:

5 frames /usr/lib/python3.10/json/init.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 345 parse_constant is None and object_pairs_hook is None and not kw): --> 346 return _default_decoder.decode(s) 347 if cls is None:

/usr/lib/python3.10/json/decoder.py in decode(self, s, _w) 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end()

/usr/lib/python3.10/json/decoder.py in raw_decode(self, s, idx) 354 except StopIteration as err: --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None 356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

JSONDecodeError Traceback (most recent call last)

in () ----> 1 sofascore.scrape_league_stats('22/23', 'La Liga', accumulation='total') /usr/local/lib/python3.10/dist-packages/ScraperFC/Sofascore.py in scrape_league_stats(self, year, league, accumulation, selected_positions) 187 f'&filters=position.in.{positions}' 188 response = requests.get(request_url, headers=self.requests_headers) --> 189 new_df = pd.DataFrame(response.json()['results']) 190 new_df['player'] = new_df.player.apply(pd.Series)['name'] 191 new_df['team'] = new_df.team.apply(pd.Series)['name'] /usr/local/lib/python3.10/dist-packages/requests/models.py in json(self, **kwargs) 973 # Catch JSON-related errors and raise as requests.JSONDecodeError 974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError --> 975 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) 976 977 @property JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It gave the same error with other functions of ScraperFC.

cristianomg10 commented 3 months ago

I'm also having this issue.

oseymour commented 3 months ago

You're getting this with every ScraperFC module?

rayml11 commented 3 months ago

im getting that with the whole module

oseymour commented 2 days ago

Should be fixed in v3.0.0. Please re-open if it's not!