You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
1.1 KiB

#!/bin/sh
basedir="$(cd $(dirname $0); pwd)"
set -e
file=urls-test.txt
if [ "$1" ] ; then
file="$1"
fi
if [ ! -d har-data ]; then mkdir har-data ; 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"
kmlfile="kml-data/$filename.kml"
if [ ! -e "$harfile" ] ; then
echo "info: testing $url"
if xvfb-run phantomjs --ssl-protocol any $basedir/netsniff.js "$url" > "$harfile.new" &&
[ -s "$harfile.new" ] &&
[ "$(jq -r '.log | .entries | map(.request) | map(.url) | join("\n")' $harfile.new)" ]; then
mv "$harfile.new" "$harfile"
else
echo "error: unable to handle $url"
if ! rm "$harfile.new" ; then
echo "error: unable to remove $harfile.new"
fi
fi
else
echo "info: not contacting "$url", already had $harfile"
fi
;;
esac
done