Created
April 26, 2021 15:21
-
-
Save prs-watch/63274292c70a223fa38b8761d6433a01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using HTTP, CSV, DataFrames | |
| URL_FORMAT_STR = "https://baseballsavant.mlb.com/statcast_search/csv?all=true&hfPT=&hfAB=&hfBBT=&hfPR=&hfZ=&stadium=&hfBBL=&hfNewZones=&hfGT=R%7CPO%7CS%7C=&hfSea=&hfSit=&player_type=pitcher&hfOuts=&opponent=&pitcher_throws=&batter_stands=&hfSA=&game_date_gt={start_dt}&game_date_lt={end_dt}&team=&position=&hfRO=&home_road=&hfFlag=&metric_1=&hfInn=&min_pitches=0&min_results=0&group_by=name&sort_col=pitches&player_event_sort=h_launch_speed&sort_order=desc&min_abs=0&type=details&" | |
| function statcast(start_dt=nothing, end_dt=nothing) | |
| if start_dt === nothing | |
| start_dt = string(today()) | |
| end | |
| if end_dt === nothing | |
| end_dt = start_dt | |
| end | |
| url = replace(replace(URL_FORMAT_STR, "{start_dt}" => start_dt), "{end_dt}" => end_dt) | |
| res = HTTP.get(url) | |
| data = CSV.File(res.body) | |
| return DataFrame(data) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment