probberechts / soccerdata

⛏⚽ Scrape soccer data from Club Elo, ESPN, FBref, FiveThirtyEight, Football-Data.co.uk, FotMob, Sofascore, SoFIFA, Understat and WhoScored.
https://soccerdata.readthedocs.io/en/latest/
Other
529 stars 90 forks source link

[WhoScored] requirejs is not defined #628

Closed chrisdebo closed 6 days ago

chrisdebo commented 6 days ago

Hi, Scraping works fine for me except for EURO 2024. It worked last time I tried it on 21th of June.

The same code still works for other leagues.

I updated chrome, chromedriver, soccerdata and all dependencies.

My Code: `import soccerdata as sd

league = 'INT-European Championship' season = '2024'

whoscored = sd.WhoScored(leagues=[league], seasons=season) df = whoscored.read_schedule()

def process_row(row): match_id = row['game_id'] try: print(f"processing match: {match_id}") whoscored.read_events(match_id=match_id, force_cache=True, output_fmt='events') except Exception as e: print(f"error while processing match: {match_id}") print(f"errordetails: {e}")

df.apply(process_row, axis=1)`

I always get this error:

[07/04/24 09:36:53] ERROR Error while scraping _common.py:655 https://www.whoscored.com/Matches/18
26802/Live. Retrying in 30
seconds... (attempt 4 of 5).
Traceback (most recent call last):
File
"/Users/chris/anaconda3/envs/whosco
red-scraping/lib/python3.11/site-pac
kages/soccerdata/_common.py", line
646, in _download_and_save
response =
json.dumps(self._driver.execute_scri
pt("return " + var)).encode(
^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/chris/anaconda3/envs/whosco
red-scraping/lib/python3.11/site-pac
kages/selenium/webdriver/remote/webd
river.py", line 414, in
execute_script
return self.execute(command,
{"script": script, "args":
converted_args})["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^
File
"/Users/chris/anaconda3/envs/whosco
red-scraping/lib/python3.11/site-pac
kages/selenium/webdriver/remote/webd
river.py", line 354, in execute
self.error_handler.check_respons
e(response)
File
"/Users/chris/anaconda3/envs/whosco
red-scraping/lib/python3.11/site-pac
kages/selenium/webdriver/remote/erro
rhandler.py", line 229, in
check_response
raise exception_class(message,
screen, stacktrace)
selenium.common.exceptions.Javascrip
tException: Message: javascript
error: requirejs is not defined

and

Traceback (most recent call last): File "/Users/chris/anaconda3/envs/whoscored-scraping/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3553, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 2, in whoscored.read_events(match_id=match_id, output_fmt='events') File "/Users/chris/anaconda3/envs/whoscored-scraping/lib/python3.11/site-packages/soccerdata/whoscored.py", line 703, in read_events reader = self.get( ^^^^^^^^^ File "/Users/chris/anaconda3/envs/whoscored-scraping/lib/python3.11/site-packages/soccerdata/_common.py", line 306, in get return self._download_and_save(url, filepath, var) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/chris/anaconda3/envs/whoscored-scraping/lib/python3.11/site-packages/soccerdata/_common.py", line 665, in _download_and_save raise ConnectionError(f"Could not download {url}.") ConnectionError: Could not download https://www.whoscored.com/Matches/1826802/Live.

probberechts commented 6 days ago

Duplicate of #617. Updating should fix this.