1
This commit is contained in:
Alex Yatskov 2015-08-22 15:20:38 +09:00
parent eb4c14d5aa
commit 495e33b298
5 changed files with 2044 additions and 33 deletions

1966
data/stations.json Normal file

File diff suppressed because it is too large Load Diff

16
data/urls.txt Normal file
View File

@ -0,0 +1,16 @@
http://tabelog.com/en/kanagawa/rstLst/
http://www.tripadvisor.com/Restaurants-g298173-Yokohama_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g298172-Kawasaki_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021282-Sagamihara_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021277-Fujisawa_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g303156-Kamakura_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g298174-Yokosuka_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021278-Odawara_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g681222-Hiratsuka_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g298169-Atsugi_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021286-Yamato_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021279-Chigasaki_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021285-Hadano_Kanagawa_Prefecture_Kanto.html

View File

@ -66,19 +66,19 @@ func scrapeUrls(filename string, wc *webCache, gc *geoCache) ([]restaurant, erro
func main() {
gc, err := newGeoCache("cache/geocache.json")
if err != nil {
log.Fatal(err)
panic(err)
}
defer gc.save()
wc, err := newWebCache("cache/webcache")
if err != nil {
log.Fatal(err)
panic(err)
}
restaurants, err := scrapeUrls("urls.txt", wc, gc)
restaurants, err := scrapeUrls("data/urls.txt", wc, gc)
if err == nil {
log.Print(len(restaurants))
} else {
log.Fatal(err)
panic(err)
}
}

58
stations.go Normal file
View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package main
import (
"encoding/json"
"os"
)
type station struct {
Latitude float64
Longitude float64
}
type stationQuery struct {
stations map[string]station
}
func newStationQuery(filename string) (*stationQuery, error) {
s := new(stationQuery)
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
if err := json.NewDecoder(file).Decode(&s.stations); err != nil {
return nil, err
}
return s, nil
}
func (s *stationQuery) closestStation(latitude, longitude float64) (name string, distance float64) {
return "", 0
}

View File

@ -1,29 +0,0 @@
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1401&LstAre=A140101&lat=35.465808055555996&lon=139.61964361111&zoom=16&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1405&LstAre=A140501&lat=35.526987222222&lon=139.70313527778&zoom=15&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1407&LstAre=A140701&lat=35.562953333333&lon=139.36054222222&zoom=12&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1404&LstAre=A140404&lat=35.348035555556&lon=139.46422555556&zoom=13&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1404&LstAre=A140402&lat=35.307700833333&lon=139.53340527778&zoom=13&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1406&LstAre=A140601&lat=35.276735833333&lon=139.67605583333&zoom=12&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1409&LstAre=A140901&lat=35.256132777778&lon=139.15514944443999&zoom=14&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1404&LstAre=A140407&lat=35.330531666667&lon=139.345865&zoom=14&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1408&LstAre=A140802&lat=35.439903888889&lon=139.36311694443998&zoom=14&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1407&LstAre=A140702&lat=35.472693611111005&lon=139.46422555556&zoom=12&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1404&LstAre=A140406&lat=35.355736111111&lon=139.40259916667&zoom=13&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://tabelog.com/en/kanagawa/rstLst/?utf8=%E2%9C%93&maxLat=&minLat=&maxLon=&minLon=&LstPrf=A1408&LstAre=A140804&lat=35.377153611111005&lon=139.20982333333&zoom=13&genre_name=&RdoCosTp=2&LstCos=0&LstCosT=11&ChkCard=&LstSitu=0&LstRev=0&LstReserve=0&ChkParking=0&LstSmoking=0&SrtT=trend&PG=
http://www.tripadvisor.com/Restaurants-g298173-Yokohama_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g298172-Kawasaki_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021282-Sagamihara_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021277-Fujisawa_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g303156-Kamakura_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g298174-Yokosuka_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021278-Odawara_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g681222-Hiratsuka_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g298169-Atsugi_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021286-Yamato_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021279-Chigasaki_Kanagawa_Prefecture_Kanto.html
http://www.tripadvisor.com/Restaurants-g1021285-Hadano_Kanagawa_Prefecture_Kanto.html