-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdprd.sh
71 lines (70 loc) · 2.05 KB
/
dprd.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
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
# author : Nur Aini Rakhmawati
# License : Apache
# February 2019
# Cara menjalankan: ./dprd.sh linkdprd
# peringatan: gunakan dengan bijaksana tanpa membebani server KPU
filename=$1
n=1
echo "dapil;partai;nama;jk;lokasi;umur;agama;nikah;pasangan;pendidikan;pekerjaan;status;motivasi;target" > calegdprd.csv
while read line; do
echo "Line No. $n : $line"
n=$((n+1))
curl -k -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8)" -o temp -L --silent --connect-timeout 20 "$line" > /dev/null
daerah=`echo $line |cut -d/ -f 4`
if [[ -f temp ]]; then
awk '/odd/,/tbody/' temp > temp1
sed 's/<a href=\"//g' temp1 > temp
sed 's/\" target=\"_blank\" rel=\"noopener\">Detail<\/a>//g' temp > temp1
sed -e 's/<[^>]*>//g' temp1 > temp
grep . temp > temp1
while read data; do
partai=$data
read data
read data
nama=$data
read data
jk=$data
read data
lokasi=$data
read data
url=$data
echo "$partai;$nama;$jk;$lokasi"
agama="-"
nikah="-"
pasangan="-"
edu="-"
kerja="-"
status="-"
motivasi="-"
target="-"
umur="-"
curl -k -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8)" -o temp -L --silent --connect-timeout 20 "$url/$x" > /dev/null
if [[ -f temp ]]; then
grep "col-sm-9" temp > temp2
jml=$(wc -l < temp2)
if [[ "$jml" -gt 5 ]]
then
sed -e 's/<[^>]*>//g' temp2 | awk '{$1=$1;print}' > temp
tahun=`awk 'NR==8' temp| cut -d "-" -f 3`
if [[ $tahun =~ ^(19|20)\d{2}$ ]]; then
umur=$((2019-$tahun))
else
umur='-'
fi
echo $tahun
agama=`awk 'NR==10' temp`
nikah=`awk 'NR==11' temp`
pasangan=`awk 'NR==12' temp`
edu=`awk 'NR==15' temp`
kerja=`awk 'NR==16' temp`
status=`awk 'NR==17' temp`
motivasi=`awk 'NR==18' temp`
target=`awk 'NR==19' temp`
rm temp temp2
fi
fi
echo "$daerah;$partai;$nama;$jk;$lokasi;$tahun;$agama;$nikah;$pasangan;$edu;$kerja;$status;$motivasi;$target" >> calegdprd.csv
done < temp1
rm temp1 temp temp2
fi
done < $filename