From 4504a6a6fd0b6c9e3c40656c97eb3700c30d59c0 Mon Sep 17 00:00:00 2001 From: Ben Dilday Date: Fri, 30 Aug 2024 08:39:54 -0400 Subject: [PATCH] pass user agent to get request --- pybaseball/top_prospects.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pybaseball/top_prospects.py b/pybaseball/top_prospects.py index e81a5fb6..ed800dcd 100644 --- a/pybaseball/top_prospects.py +++ b/pybaseball/top_prospects.py @@ -22,8 +22,16 @@ def top_prospects(teamName=None, playerType=None): else: mlbTeamId = teamid_lookup.mlb_team_id(teamName) url = f"https://www.mlb.com/prospects/stats?teamId={mlbTeamId}" - - res = requests.get(url, timeout=None).content + + res = requests.get( + url, + timeout=None, + headers={ + "UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " + "AppleWebKit/537.36 (KHTML, like Gecko) C" + "hrome/104.0.5112.79 Safari/537.36" + }, + ).content prospectList = pd.read_html(res) if playerType == "batters":