Skip to content

Instantly share code, notes, and snippets.

@samm81
Created January 18, 2021 00:38
Show Gist options
  • Save samm81/b7833e6c0529c0950d143c06dc5612ce to your computer and use it in GitHub Desktop.
Save samm81/b7833e6c0529c0950d143c06dc5612ce to your computer and use it in GitHub Desktop.
Jefit.com workout scraper
# first and last days of data you want to export
start_date='2015-01-01'
end_date='2020-12-31'
curl_date() {
date="$1"
# you'll need to replace the cookie info with your cookie info
# you can get this info by logging into the jefit website then going to the web console "network" section, refreshing, and right clicking on the root request and selecting "copy as curl"
curl "https://www.jefit.com/my-jefit/my-logs/log/?dd=$date" \
-H 'Cookie: PHPSESSID=1111111111AAAAAAAAAA; dfsessionhash=11111111111aaaaaaaaaa; dflastvisit=11111111; dflastactivity=1111111111; dfpassword=111111111111111111111111aaaaaaaaaaaaaaaaaaa; dfuserid=11111111' \
--compressed
}
get_date() {
date="$1"
# tee sends the `curl`ed webpage to "/tmp/$date.html" and to `stdout`
# where grep can check if the string "No workout sessions" appears
# this whole thing is wrapped in a `!`, so only if "No workout sessions *doesn't* appear
# do we `mv` the `curl`ed webpage to the current folder
if ! curl_date "$date" | tee "/tmp/$date.html" | grep -q "No workout sessions"; then
mv "/tmp/$date.html" "./$date.html"
fi
}
date="$start_date"
while [ "$date" != "$end_date" ]; do
get_date "$date"
date=$(date -I -d "$date +1day")
done
get_date "$date"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment