Skip to content

Instantly share code, notes, and snippets.

@mwdchang
Created March 16, 2018 11:27
Show Gist options
  • Save mwdchang/0b834bb77b7e2456b9a09962067161a3 to your computer and use it in GitHub Desktop.
Save mwdchang/0b834bb77b7e2456b9a09962067161a3 to your computer and use it in GitHub Desktop.
Scrapes baseball reference player mug shots
#!/usr/bin/env bash
PLAYER_ID=$1
IDX=${PLAYER_ID:0:1}
URL="https://www.baseball-reference.com/players/${IDX}/${PLAYER_ID}.shtml"
echo "$URL"
curl ${URL} | grep "og:image" | egrep -o "http.*((jpg)|(png))" | xargs curl -o ${PLAYER_ID}
sips -s format jpeg ${PLAYER_ID} --out ${PLAYER_ID}.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment