-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·36 lines (27 loc) · 1.16 KB
/
start.sh
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
31
32
33
34
#!/bin/bash
set -u
wait_seconds_after_nav=10
# get new screenshots
while read -r url_conf; do
url=`echo $url_conf | cut -d' ' -f1`
l_offset=`echo $url_conf | cut -d' ' -f2`
t_offset=`echo $url_conf | cut -d' ' -f3`
r_offset=`echo $url_conf | cut -d' ' -f4`
b_offset=`echo $url_conf | cut -d' ' -f5`
h=`echo $url | md5sum | awk '{ print $1 }'`
dir="ss_$h"
old_dir="${dir}_old"
mkdir -p $dir
mkdir -p $old_dir
cp $dir/* $old_dir/
# this Docker container creates a `screenshot/` folder in the current directory and downloads a screenshot of the given website
docker run -v $(pwd):/data leonjza/gowitness gowitness single --screenshot-path $dir --delay $wait_seconds_after_nav --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" "$url"
# find if there is any change in one of the websites in urls.txt
result="$(python3 check_image_diff.py $dir $l_offset $t_offset $r_offset $b_offset)"
if [ -z "$result" ]
then
echo "no change"
else
curl -H "Content-Type: application/json" -d "{\"username\": \"test\", \"content\": \"$url\"}" "${DISCORD_WEBHOOK}"
fi
done < urls.txt