-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (37 loc) · 862 Bytes
/
main.go
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
package main
import (
"fmt"
"log"
"time"
)
func main() {
meituan := NewMeituan()
meituan.HeadHome() // for set cookie
cityList, err := LoadCityList("citylist.txt")
if err != nil {
cityList, err = meituan.GetCityList()
if err != nil {
log.Fatalln(err)
}
if err := cityList.Save("citylist.txt"); err != nil {
log.Fatalln(err)
}
}
city := cityList.GetCity("上海")
if city == nil {
log.Fatalln("city not found")
}
fmt.Println(city.Id, city.Name, city.Acronym)
if err := meituan.WalkMeishi(city.Acronym, func(poiInfos []*MeishiPoiInfoData) {
for _, poiInfo := range poiInfos {
detailInfo, err := meituan.GetMeishiDetailInfo(poiInfo.PoiId)
if err != nil {
log.Fatalln(err)
}
fmt.Println(detailInfo.PoiId, detailInfo.Name, detailInfo.Phone)
time.Sleep(time.Second)
}
}); err != nil {
log.Fatalln(err)
}
}