summaryrefslogtreecommitdiff
path: root/curl_iowastate.sh
diff options
context:
space:
mode:
authorClay Smith <claysmith158@gmail.com>2023-08-01 01:01:56 -0500
committerClay Smith <claysmith158@gmail.com>2023-08-01 01:01:56 -0500
commitecb28155a6afcbe4c50ebe8e6bc112ff884af48a (patch)
tree9cd293fc1aa0473d370bf0167f51e5e8f5248f5e /curl_iowastate.sh
First commitHEADmain
Diffstat (limited to 'curl_iowastate.sh')
-rwxr-xr-xcurl_iowastate.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/curl_iowastate.sh b/curl_iowastate.sh
new file mode 100755
index 0000000..6fbcaf9
--- /dev/null
+++ b/curl_iowastate.sh
@@ -0,0 +1,20 @@
+#/bin/bash
+
+IFS=$","
+
+declare -a buildings=( $(curl -s https://www.fpm.iastate.edu/maps/buildings/ | awk '/var buildingNames/{ f = 1; next } /];/{ f = 0 } f' | tr -d '"' | tr ' ' '+') )
+
+URL="https://www.fpm.iastate.edu/maps/buildings/building.asp?building="
+
+echo "" > /tmp/building_urls.txt
+for ((i = 0; i < ${#buildings[@]}; ++i))
+do
+ printf "$URL${buildings[i]}\n" >> /tmp/building_urls.txt
+done
+
+if [ "$1" = "reload" ]; then
+ echo "" > /tmp/building_html_time.txt
+ parallel curl -s {} < /tmp/building_urls.txt | grep "mt-3\|Monday" >> /tmp/building_html_time.txt
+fi
+
+cat /tmp/building_html_time.txt | grep "mt-3\|tr.*th>" | grep "Monday" -B1 | sed -e 's/--//g' -e 's/<h2 class="mt-3">/\n/g' -e 's/<\/h2>//g' -e 's/<tr><th>//g' -e 's/<\/th><td>/ /g' -e 's/<\/td>/ /g' -e 's/<\/tr>//g' | tee times.txt