-
Notifications
You must be signed in to change notification settings - Fork 0
/
spider_info.go
36 lines (30 loc) · 755 Bytes
/
spider_info.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
package main
import (
"github.com/anaskhan96/soup"
)
type WebBody struct {
body string
}
type ShopValue struct {
Name string `名字`
Address string `地址`
Phone string `电话`
}
func NewWebBody(content string) WebBody {
return WebBody{body: content}
}
func (wb WebBody) SpiderAddress() string {
htmlInfo := soup.HTMLParse(wb.body)
address := htmlInfo.Find("body").Find("div", "class", "main")
return address.FullText()
}
func (wb WebBody) SpiderInfo() ShopValue {
htmlInfo := soup.HTMLParse(wb.body)
shopSoup := htmlInfo.Find("body").Find("div", "class", "main")
address := shopSoup.Find("div", "id", "J_map-show").FullText()
phone := shopSoup.Find("p").FullText()
return ShopValue{
Address: address,
Phone: phone,
}
}