Skip to content

Commit

Permalink
fix(WhoScored): update URL parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
probberechts committed Jan 16, 2025
1 parent 9576fe8 commit 1b81895
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions soccerdata/whoscored.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import numpy as np
import pandas as pd
from lxml import html
from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException
from selenium.common.exceptions import (
ElementClickInterceptedException,
NoSuchElementException,
)
from selenium.webdriver.common.by import By

from ._common import BaseSeleniumReader, make_game_id, standardize_colnames
Expand Down Expand Up @@ -88,13 +91,13 @@ def _parse_url(url: str) -> dict:
"""
patt = (
r"^(?:https:\/\/www.whoscored.com)?\/"
+ r"(?:Regions\/(\d+)\/)?"
+ r"(?:Tournaments\/(\d+)\/)?"
+ r"(?:Seasons\/(\d+)\/)?"
+ r"(?:Stages\/(\d+)\/)?"
+ r"(?:Matches\/(\d+)\/)?"
+ r"(?:regions\/(\d+)\/)?"
+ r"(?:tournaments\/(\d+)\/)?"
+ r"(?:seasons\/(\d+)\/)?"
+ r"(?:stages\/(\d+)\/)?"
+ r"(?:matches\/(\d+)\/)?"
)
matches = re.search(patt, url)
matches = re.search(patt, url, re.IGNORECASE)
if matches:
return {
"region_id": matches.group(1),
Expand Down

0 comments on commit 1b81895

Please sign in to comment.