1
This commit is contained in:
Alex Yatskov 2015-08-17 15:47:20 +09:00
parent 3789b8986b
commit 50221007aa
4 changed files with 104 additions and 22 deletions

96
cache/geocache.json vendored
View File

@ -123,6 +123,10 @@
"Latitude": 35.2529848, "Latitude": 35.2529848,
"Longitude": 139.1571151 "Longitude": 139.1571151
}, },
"1-10-10 Tsunashimanishi Kohoku-ku Yokohama Kanagawa": {
"Latitude": 35.5370142,
"Longitude": 139.6323933
},
"1-10-12 Okano Nishi-ku Yokohama Kanagawa": { "1-10-12 Okano Nishi-ku Yokohama Kanagawa": {
"Latitude": 35.4626611, "Latitude": 35.4626611,
"Longitude": 139.616274 "Longitude": 139.616274
@ -407,6 +411,10 @@
"Latitude": 35.3522493, "Latitude": 35.3522493,
"Longitude": 139.5328241 "Longitude": 139.5328241
}, },
"1-22-7 Kizuki Nakahara-ku Kawasaki Kanagawa": {
"Latitude": 35.5654286,
"Longitude": 139.6535961
},
"1-23 Sueyoshicho Naka-ku Yokohama Kanagawa": { "1-23 Sueyoshicho Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4416664, "Latitude": 35.4416664,
"Longitude": 139.6274652 "Longitude": 139.6274652
@ -443,6 +451,10 @@
"Latitude": 35.4408026, "Latitude": 35.4408026,
"Longitude": 139.64975 "Longitude": 139.64975
}, },
"1-26-7 Azamino Aoba-ku Yokohama Kanagawa": {
"Latitude": 35.5698719,
"Longitude": 139.5445204
},
"1-27-2 Motomachi Naka-ku Yokohama Kanagawa": { "1-27-2 Motomachi Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4408248, "Latitude": 35.4408248,
"Longitude": 139.6498083 "Longitude": 139.6498083
@ -451,6 +463,10 @@
"Latitude": 35.5081315, "Latitude": 35.5081315,
"Longitude": 139.6788956 "Longitude": 139.6788956
}, },
"1-3 Yamatocho Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4315844,
"Longitude": 139.6484725
},
"1-3-1 Minamisaiwai Nishi-ku Yokohama Kanagawa": { "1-3-1 Minamisaiwai Nishi-ku Yokohama Kanagawa": {
"Latitude": 35.4673383, "Latitude": 35.4673383,
"Longitude": 139.6220148 "Longitude": 139.6220148
@ -815,6 +831,10 @@
"Latitude": 35.4100343, "Latitude": 35.4100343,
"Longitude": 139.5972576 "Longitude": 139.5972576
}, },
"1-9-27 Yukinoshita Kamakura Kanagawa": {
"Latitude": 35.3224057,
"Longitude": 139.5538502
},
"1-9-8 Tsurumichuo Tsurumi-ku Yokohama Kanagawa": { "1-9-8 Tsurumichuo Tsurumi-ku Yokohama Kanagawa": {
"Latitude": 35.5096674, "Latitude": 35.5096674,
"Longitude": 139.6770818 "Longitude": 139.6770818
@ -899,10 +919,18 @@
"Latitude": 35.5420649, "Latitude": 35.5420649,
"Longitude": 139.5745105 "Longitude": 139.5745105
}, },
"120 Maekawa Odawara Kanagawa": {
"Latitude": 35.2810794,
"Longitude": 139.1943117
},
"1297 Ninotaira Hakone Ashigarashimo-gun Kanagawa": { "1297 Ninotaira Hakone Ashigarashimo-gun Kanagawa": {
"Latitude": 35.2416651, "Latitude": 35.2416651,
"Longitude": 139.0432767 "Longitude": 139.0432767
}, },
"13-6 Shineicho Chigasaki Kanagawa": {
"Latitude": 35.3319681,
"Longitude": 139.403747
},
"131-12 Yamashitacho Naka-ku Yokohama Kanagawa": { "131-12 Yamashitacho Naka-ku Yokohama Kanagawa": {
"Latitude": 35.44195800000001, "Latitude": 35.44195800000001,
"Longitude": 139.6459557 "Longitude": 139.6459557
@ -1159,6 +1187,10 @@
"Latitude": 35.2808246, "Latitude": 35.2808246,
"Longitude": 139.6706478 "Longitude": 139.6706478
}, },
"2-10 Takanecho Minami-ku Yokohama Kanagawa": {
"Latitude": 35.4371475,
"Longitude": 139.6255822
},
"2-10 Tokiwacho Naka-ku Yokohama Kanagawa": { "2-10 Tokiwacho Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4453798, "Latitude": 35.4453798,
"Longitude": 139.6380727 "Longitude": 139.6380727
@ -1167,6 +1199,10 @@
"Latitude": 35.5827894, "Latitude": 35.5827894,
"Longitude": 139.5648015 "Longitude": 139.5648015
}, },
"2-10-1 Kobuchi Minami-ku Sagamihara Kanagawa": {
"Latitude": 35.5536635,
"Longitude": 139.4167815
},
"2-10-10 Komachi Kamakura Kanagawa": { "2-10-10 Komachi Kamakura Kanagawa": {
"Latitude": 35.3200976, "Latitude": 35.3200976,
"Longitude": 139.5522336 "Longitude": 139.5522336
@ -1331,6 +1367,10 @@
"Latitude": 35.4637304, "Latitude": 35.4637304,
"Longitude": 139.6160934 "Longitude": 139.6160934
}, },
"2-172-8 Kosugigotencho Nakahara-ku Kawasaki Kanagawa": {
"Latitude": 35.5814201,
"Longitude": 139.6547782
},
"2-18-1 Takashima Nishi-ku Yokohama Kanagawa": { "2-18-1 Takashima Nishi-ku Yokohama Kanagawa": {
"Latitude": 35.4655663, "Latitude": 35.4655663,
"Longitude": 139.6253063 "Longitude": 139.6253063
@ -1443,6 +1483,10 @@
"Latitude": 35.59388879999999, "Latitude": 35.59388879999999,
"Longitude": 139.4986834 "Longitude": 139.4986834
}, },
"2-26 Otamachi Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4466797,
"Longitude": 139.6390865
},
"2-27-6 Mizonokuchi Takatsu-ku Kawasaki Kanagawa": { "2-27-6 Mizonokuchi Takatsu-ku Kawasaki Kanagawa": {
"Latitude": 35.6013647, "Latitude": 35.6013647,
"Longitude": 139.6095762 "Longitude": 139.6095762
@ -1643,6 +1687,10 @@
"Latitude": 35.4476545, "Latitude": 35.4476545,
"Longitude": 139.6297149 "Longitude": 139.6297149
}, },
"2-6-1 Hagoromocho Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4435162,
"Longitude": 139.6344703
},
"2-6-11 Isago Kawasaki-ku Kawasaki Kanagawa": { "2-6-11 Isago Kawasaki-ku Kawasaki Kanagawa": {
"Latitude": 35.5289338, "Latitude": 35.5289338,
"Longitude": 139.7004514 "Longitude": 139.7004514
@ -1779,6 +1827,10 @@
"Latitude": 35.3490264, "Latitude": 35.3490264,
"Longitude": 139.4529475 "Longitude": 139.4529475
}, },
"2-9-14 Kamiookanishi Konan-ku Yokohama Kanagawa": {
"Latitude": 35.4059042,
"Longitude": 139.5950495
},
"2-9-50 Chuo Ebina Kanagawa": { "2-9-50 Chuo Ebina Kanagawa": {
"Latitude": 35.4502509, "Latitude": 35.4502509,
"Longitude": 139.3954138 "Longitude": 139.3954138
@ -1883,6 +1935,10 @@
"Latitude": 35.3748917, "Latitude": 35.3748917,
"Longitude": 139.6102816 "Longitude": 139.6102816
}, },
"276 Yamashitacho Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4399138,
"Longitude": 139.6449142
},
"3-1 Misumicho Chigasaki Kanagawa": { "3-1 Misumicho Chigasaki Kanagawa": {
"Latitude": 35.332547, "Latitude": 35.332547,
"Longitude": 139.428279 "Longitude": 139.428279
@ -1895,6 +1951,10 @@
"Latitude": 35.4711859, "Latitude": 35.4711859,
"Longitude": 139.462331 "Longitude": 139.462331
}, },
"3-1-22 Nakacho Atsugi Kanagawa": {
"Latitude": 35.4397128,
"Longitude": 139.3629777
},
"3-1-23 Nakacho Atsugi Kanagawa": { "3-1-23 Nakacho Atsugi Kanagawa": {
"Latitude": 35.4394934, "Latitude": 35.4394934,
"Longitude": 139.3629972 "Longitude": 139.3629972
@ -1947,6 +2007,10 @@
"Latitude": 35.3298511, "Latitude": 35.3298511,
"Longitude": 139.4696183 "Longitude": 139.4696183
}, },
"3-12-6 Sagamiono Minami-ku Sagamihara Kanagawa": {
"Latitude": 35.53185819999999,
"Longitude": 139.4361665
},
"3-13-1 Shinjo Nakahara-ku Kawasaki Kanagawa": { "3-13-1 Shinjo Nakahara-ku Kawasaki Kanagawa": {
"Latitude": 35.5849827, "Latitude": 35.5849827,
"Longitude": 139.6302862 "Longitude": 139.6302862
@ -1975,6 +2039,10 @@
"Latitude": 35.5784848, "Latitude": 35.5784848,
"Longitude": 139.5655405 "Longitude": 139.5655405
}, },
"3-16-8 Sagamiono Minami-ku Sagamihara Kanagawa": {
"Latitude": 35.53224420000001,
"Longitude": 139.4352138
},
"3-17-15 Shinyokohama Kohoku-ku Yokohama Kanagawa": { "3-17-15 Shinyokohama Kohoku-ku Yokohama Kanagawa": {
"Latitude": 35.5112221, "Latitude": 35.5112221,
"Longitude": 139.6183094 "Longitude": 139.6183094
@ -2087,6 +2155,10 @@
"Latitude": 35.3817738, "Latitude": 35.3817738,
"Longitude": 139.5029676 "Longitude": 139.5029676
}, },
"3-41 Bentendori Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4480239,
"Longitude": 139.6382254
},
"3-417 Kosugimachi Nakahara-ku Kawasaki Kanagawa": { "3-417 Kosugimachi Nakahara-ku Kawasaki Kanagawa": {
"Latitude": 35.5758545, "Latitude": 35.5758545,
"Longitude": 139.6583923 "Longitude": 139.6583923
@ -2111,6 +2183,10 @@
"Latitude": 35.5760448, "Latitude": 35.5760448,
"Longitude": 139.6576346 "Longitude": 139.6576346
}, },
"3-44-1 Minamikamonomiya Odawara Kanagawa": {
"Latitude": 35.2747634,
"Longitude": 139.1806026
},
"3-472 Kosugimachi Nakahara-ku Kawasaki Kanagawa": { "3-472 Kosugimachi Nakahara-ku Kawasaki Kanagawa": {
"Latitude": 35.5756545, "Latitude": 35.5756545,
"Longitude": 139.6595533 "Longitude": 139.6595533
@ -2407,10 +2483,18 @@
"Latitude": 35.53018369999999, "Latitude": 35.53018369999999,
"Longitude": 139.6990264 "Longitude": 139.6990264
}, },
"5-2-11 Sahara Yokosuka Kanagawa": {
"Latitude": 35.2372732,
"Longitude": 139.6929399
},
"5-2-15 Utsukushigaoka Aoba-ku Yokohama Kanagawa": { "5-2-15 Utsukushigaoka Aoba-ku Yokohama Kanagawa": {
"Latitude": 35.5760796, "Latitude": 35.5760796,
"Longitude": 139.5554332 "Longitude": 139.5554332
}, },
"5-2-2 Nagatsuta Midori-ku Yokohama Kanagawa": {
"Latitude": 35.5312232,
"Longitude": 139.4953191
},
"5-2-40 Zushi Zushi Kanagawa": { "5-2-40 Zushi Zushi Kanagawa": {
"Latitude": 35.2957559, "Latitude": 35.2957559,
"Longitude": 139.5787785 "Longitude": 139.5787785
@ -2479,6 +2563,10 @@
"Latitude": 35.3636858, "Latitude": 35.3636858,
"Longitude": 139.453978 "Longitude": 139.453978
}, },
"53-1 Fukutomicho Nishidori Naka-ku Yokohama Kanagawa": {
"Latitude": 35.4458768,
"Longitude": 139.6311229
},
"535 Shinanocho Totsuka-ku Yokohama Kanagawa": { "535 Shinanocho Totsuka-ku Yokohama Kanagawa": {
"Latitude": 35.4305504, "Latitude": 35.4305504,
"Longitude": 139.5618854 "Longitude": 139.5618854
@ -2531,6 +2619,10 @@
"Latitude": 35.2067628, "Latitude": 35.2067628,
"Longitude": 139.1316628 "Longitude": 139.1316628
}, },
"59-1 Kamigocho Sakae-ku Yokohama Kanagawa": {
"Latitude": 35.3636257,
"Longitude": 139.5653552
},
"599 Kamonomiya Odawara Kanagawa": { "599 Kamonomiya Odawara Kanagawa": {
"Latitude": 35.2812984, "Latitude": 35.2812984,
"Longitude": 139.1775054 "Longitude": 139.1775054
@ -2823,6 +2915,10 @@
"Latitude": 35.475278, "Latitude": 35.475278,
"Longitude": 139.5464557 "Longitude": 139.5464557
}, },
"神奈川県横浜市都筑区茅ヶ崎中央3-25": {
"Latitude": 35.5447285,
"Longitude": 139.5745799
},
"神奈川県横浜市都筑区茅ヶ崎中央6-1": { "神奈川県横浜市都筑区茅ヶ崎中央6-1": {
"Latitude": 35.5439813, "Latitude": 35.5439813,
"Longitude": 139.5744244 "Longitude": 139.5744244

View File

@ -42,8 +42,8 @@ func main() {
} }
tasks := []scrapeTask{ tasks := []scrapeTask{
// {"http://tabelog.com/en/kanagawa/rstLst/1/", tabelog{}}, {"http://tabelog.com/en/kanagawa/rstLst/1/", tabelog{}},
{"http://www.tripadvisor.com/Restaurants-g298173-Yokohama_Kanagawa_Prefecture_Kanto.html", tripadvisor{}}, // {"http://www.tripadvisor.com/Restaurants-g298173-Yokohama_Kanagawa_Prefecture_Kanto.html", tripadvisor{}},
// {"http://www.tripadvisor.com/Restaurants-g1021277-Fujisawa_Kanagawa_Prefecture_Kanto.html", tripadvisor{}}, // {"http://www.tripadvisor.com/Restaurants-g1021277-Fujisawa_Kanagawa_Prefecture_Kanto.html", tripadvisor{}},
// {"http://www.tripadvisor.com/Restaurants-g1021279-Chigasaki_Kanagawa_Prefecture_Kanto.html", tripadvisor{}}, // {"http://www.tripadvisor.com/Restaurants-g1021279-Chigasaki_Kanagawa_Prefecture_Kanto.html", tripadvisor{}},
// {"http://www.tripadvisor.com/Restaurants-g298172-Kawasaki_Kanagawa_Prefecture_Kanto.html", tripadvisor{}}, // {"http://www.tripadvisor.com/Restaurants-g298172-Kawasaki_Kanagawa_Prefecture_Kanto.html", tripadvisor{}},

View File

@ -24,6 +24,7 @@ package main
import ( import (
"errors" "errors"
"fmt"
"strconv" "strconv"
"strings" "strings"
@ -60,25 +61,11 @@ func (tabelog) review(doc *goquery.Document) (name, address string, features map
} }
features = make(map[string]float64) features = make(map[string]float64)
if features["dishes"], err = strconv.ParseFloat(doc.Find("#js-rating-detail > dd:nth-child(2)").Text(), 8); err != nil { for index, category := range []string{"dishes", "service", "atmosphere", "cost", "drinks"} {
err = errors.New("invalid value for dishes") text := doc.Find(fmt.Sprintf("#js-rating-detail > dd:nth-child(%d)", (index+1)*2)).Text()
return if features[category], err = strconv.ParseFloat(text, 8); err != nil {
err = fmt.Errorf("invalid value for %s", category)
} }
if features["service"], err = strconv.ParseFloat(doc.Find("#js-rating-detail > dd:nth-child(4)").Text(), 8); err != nil {
err = errors.New("invalid value for service")
return
}
if features["atmosphere"], err = strconv.ParseFloat(doc.Find("#js-rating-detail > dd:nth-child(6)").Text(), 8); err != nil {
err = errors.New("invalid value for atmosphere")
return
}
if features["cost"], err = strconv.ParseFloat(doc.Find("#js-rating-detail > dd:nth-child(8)").Text(), 8); err != nil {
err = errors.New("invalid value for cost")
return
}
if features["drinks"], err = strconv.ParseFloat(doc.Find("#js-rating-detail > dd:nth-child(10)").Text(), 8); err != nil {
err = errors.New("invalid value for drinks")
return
} }
return return

View File

@ -64,7 +64,6 @@ func (tripadvisor) review(doc *goquery.Document) (name, address string, features
for index, category := range []string{"food", "service", "value", "atmosphere"} { for index, category := range []string{"food", "service", "value", "atmosphere"} {
alt, _ := ratings.Eq(index).Attr("alt") alt, _ := ratings.Eq(index).Attr("alt")
rating := strings.Split(alt, " ")[0] rating := strings.Split(alt, " ")[0]
if features[category], err = strconv.ParseFloat(rating, 8); err != nil { if features[category], err = strconv.ParseFloat(rating, 8); err != nil {
err = fmt.Errorf("invalid value for %s", category) err = fmt.Errorf("invalid value for %s", category)
return return