#!/bin/sh set -e file=urls-test.txt if [ "$1" ] ; then file="$1" fi cat $file | while read url ; do case "$url" in http*) # Save with URL as filename, replacing / with % and dropping trailing slash. filename=$(echo "$url" | sed 's%/$%%' |tr / %) harfile="har-data/$filename.har" if [ ! -e "$harfile" ] ; then echo "testing $url" if phantomjs netsniff.js "$url" > "$harfile.new" && [ -s "$harfile.new" ]; then mv "$harfile.new" "$harfile" else rm "$harfile.new" fi else echo found $harfile, not downloading fi if [ -e "$harfile" ] && grep -q google-analytics.com "$harfile" ; then echo "NSA/FRA warning for $url" fi ;; esac done