-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetPrices
71 lines (57 loc) · 1.01 KB
/
GetPrices
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /bin/sh
DEP=XXX
DES=XXX
DD=D/M/YYYY
DT=HH:MM
DP=XXX.XX
RD=D/M/YYYY
RT=HH:MM
RP=XXX.XX
PAS=X
URL="http://www.easyjet.com/links.mvc?dep=$DEP&dest=$DES&dd=$DD&rd=$RD&apax=$PAS"
curl -s -L -c cookies.txt -o prices.html $URL
rm cookies.txt
DNOWP=$(sed -n "
/ \{12\}£/{
N
N
N
N
N
/30\/06\/2015 $DT/{
s/<\/s.*//
s/<\/div><span>//
s/<div>//
s/ \{12\}£//
p
}
}
" prices.html)
RNOWP=$(sed -n "
/ \{12\}£/{
N
N
N
N
N
/10\/07\/2015 $RT/{
s/<\/s.*//
s/<\/div><span>//
s/<div>//
s/ \{12\}£//
p
}
}
" prices.html)
rm prices.html
DDIFF=$(echo "$DP - $DNOWP" | bc)
RDIFF=$(echo "$RP - $RNOWP" | bc)
if [[ $(echo "if ($DDIFF > 0) 1 else 0" | bc) -eq 1 ]]; then
MESSAGE="Departure flight is £$DDIFF cheaper."
fi
if [[ $(echo "if ($RDIFF > 0) 1 else 0" | bc) -eq 1 ]]; then
MESSAGE="$MESSAGE Return flight is £$RDIFF cheaper."
fi
if [[ $MESSAGE ]]; then
curl --data "apikey=XXXXX&application=EJCheck&event=Price%20Is%20Cheaper!&description=$MESSAGE" https://api.prowlapp.com/publicapi/add
fi