Created
May 24, 2021 17:17
-
-
Save notnoop/d144fb0a323056c9cd1c79adf73eaedb to your computer and use it in GitHub Desktop.
Script for getting Acera Summer 2021 camp programs in a csv table.
This file contains 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
#!/usr/bin/env bash | |
curl -sSL https://aceraschool21.wpengine.com/summer-camps-2021/ \ | |
| grep 'var localObj =' \ | |
| sed 's|.*var localObj = ||g' \ | |
| sed "s|'|\"|g" \ | |
| sed 's|";|"|g' \ | |
| sed 's| - Week | Week |g' \ | |
| sed 's| Weeks 2 & 3| Week 2.3 |g' \ | |
| jq -r . \ | |
| jq '.include_cat as $age | |
| .events[] | |
| (.title | split(" - ")) as $title_parts | |
| ($title_parts[1] | split(", ")) as $time | |
| select (.title | contains("Early Drop-Off") | not) | |
| select (.title | contains("Late Pickup") | not) | |
| {age: $age, | |
start: .start, | |
days: $time[1], | |
title: $title_parts[0], | |
part: ($time[0] | split(" Week ")[0]), | |
week: ($time[0] | split(" Week ")[1] // 0 | tonumber), | |
in_person: $title_parts[2], | |
available: .in_stock, | |
url: .url}' \ | |
| jq -r --slurp '["week", "days", "morning vs afternoon", "age", "title", "in_person", "available", "url"], (. | |
| sort_by(.start, .part, (.age | split("-")[0] | tonumber)) | |
| .[] | [.week, .days, .part, .age, .title, .in_person, .available, .url] ) | |
| @csv' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment