Last active
February 15, 2021 08:40
-
-
Save reillysiemens/7e9aea30417d28c8f59abadcd5561306 to your computer and use it in GitHub Desktop.
Check which WWU CS professors have facultyweb sites.
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
#!/bin/sh | |
FACULTYWEB='https://facultyweb.cs.wwu.edu/' | |
PROF_DIRECTORY='https://cs.wwu.edu/faculty' | |
USERNAME_PATTERN='<h2 class="title no-margin"><a href="/\K\w+' | |
PROFS=$(curl -s ${PROF_DIRECTORY} | grep -oP "${USERNAME_PATTERN}") | |
PADDING=$(for p in $PROFS; do echo $p | wc -c; done | sort | tail -1) | |
red () { | |
printf "\e[0;31m${1}\e[0;0m" | |
} | |
green () { | |
printf "\e[0;32m${1}\e[0;0m" | |
} | |
test_for_page () { | |
username=$1 | |
url="${FACULTYWEB}~${username}/" | |
suffix=$(red "✘") | |
if curl -s --fail -L --head ${url} > /dev/null; then | |
suffix="$(green "✔") (${url})" | |
fi | |
printf "%*s ${suffix}\n" "$PADDING" "${prof}" | |
} | |
test_pages () { | |
for prof in ${PROFS} | |
do | |
test_for_page ${prof} & | |
done | |
} | |
test_pages | sort | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment