-
Notifications
You must be signed in to change notification settings - Fork 1
/
guatecompras.sh
46 lines (24 loc) · 1.19 KB
/
guatecompras.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
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#Doesnt work for various pages, cURL only returns static content, needed headless-browser to exec the __doPostBAck() on n page
# TODO set up crontab on server execute every day
get_NGOs(){
STR_INPUT=$1
echo "fetching data"
# TODO function for any 'Keyword'
curl -o out.txt "http://www.guatecompras.gt/concursos/detallePorSubModConcuros.aspx?Ent=-1&Tep=-1&Te=-1&Uc=-1&Est=-1&DType=-1&NOG=&SNIP=-1&TC=-1&CAT=-1&Desc=${STR_INPUT}&MOD=-1&TRO=-1&typeS=1"
echo "http://www.guatecompras.gt/concursos/detallePorSubModConcuros.aspx?Ent=-1&Tep=-1&Te=-1&Uc=-1&Est=-1&DType=-1&NOG=&SNIP=-1&TC=-1&CAT=-1&Desc="$1"&MOD=-1&TRO=-1&typeS=1"
echo "search for NGOs"
grep -ri "NOG (Número de Operación Guatecompras)" | grep -o -P '(?<=<b>).*(?=</b></span>)' >> lines.txt
echo $(wc -l lines.txt) " matches for " "$1"
#SIZE_NGOS=$(wc -l lines.txt)
echo "valid URLs for the newest contest"
awk '$1="http://www.guatecompras.gt/concursos/consultaConcurso.aspx?nog="$1"&o=5"' < lines.txt >> NGOs.txt
echo "open first" ## check is it a valid URL
#firefox $(head -n 1 NGOs.txt) &
rm out.txt lines.txt
}
# Entry point
get_NGOs "HOSPITAL%20ROOSEVELT"
get_NGOs "HOSPITAL"
get_NGOs "COVID%2019"
get_NGOs "Escuintla"