aboutsummaryrefslogtreecommitdiffstats
path: root/runcheck
blob: f368b67a0100685599750c45f73f60d99acde5cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

set -e

file=testurls.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 found $harfile, skipping
            continue
        fi
        echo "testing $url"
        if phantomjs netsniff.js "$url" > "$harfile.new" && 
            [ -s "$harfile.new" ]; then
            mv "$harfile.new" "$harfile"
        else
            rm "$harfile.new"
        fi
        ;;
    esac
done