-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-map
executable file
·32 lines (27 loc) · 945 Bytes
/
generate-map
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
#!/bin/bash
curl='curl --silent'
base_url='http://www.taipeitravel.net/frontsite/en/sceneryEnSearchAction.do?recordCount=26&jumpToMaxRecord=50&cityId=1&fieldValue=&block=-1&menuId=1030501&method=doSearch&fieldName=10&city=1'
delimiter=" '"
output='index.html'
quoted_value() {
grep -o "'.*'" | tr -d "'"
}
cat header.html > "$output"
$curl "$base_url" |
grep scenerySerNo |
grep -o "'.*'" |
cut -d "'" -f2,4 |
sed -e 's/^ *//g' -e 's/ *$//g' |
sort -u |
while read line
do
url="http://www.taipeitravel.net/${line%$delimiter*}"
title="${line#*$delimiter}"
page="$($curl $url)"
lon="$(echo "$page" | grep "lng = '" | tail -n 1 | quoted_value)"
lat="$(echo "$page" | grep "lat = '" | tail -n 1 | quoted_value)"
echo "'$url': ['$title', new google.maps.LatLng($lat, $lon)]," >> "$output"
echo "$title"
sleep 1
done
cat footer.html >> "$output"