/
google-results.go
79 lines (77 loc) · 2.84 KB
/
google-results.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
// GoogleResults represents a set of results from the Google Custom Search API.
type GoogleResults struct {
Kind string `json:"kind"`
URL struct {
Type string `json:"type"`
Template string `json:"template"`
} `json:"url"`
Queries struct {
Request []struct {
Title string `json:"title"`
TotalResults string `json:"totalResults"`
SearchTerms string `json:"searchTerms"`
Count int `json:"count"`
StartIndex int `json:"startIndex"`
InputEncoding string `json:"inputEncoding"`
OutputEncoding string `json:"outputEncoding"`
Safe string `json:"safe"`
Cx string `json:"cx"`
} `json:"request"`
NextPage []struct {
Title string `json:"title"`
TotalResults string `json:"totalResults"`
SearchTerms string `json:"searchTerms"`
Count int `json:"count"`
StartIndex int `json:"startIndex"`
InputEncoding string `json:"inputEncoding"`
OutputEncoding string `json:"outputEncoding"`
Safe string `json:"safe"`
Cx string `json:"cx"`
} `json:"nextPage"`
} `json:"queries"`
Context struct {
Title string `json:"title"`
} `json:"context"`
SearchInformation struct {
SearchTime float64 `json:"searchTime"`
FormattedSearchTime string `json:"formattedSearchTime"`
TotalResults string `json:"totalResults"`
FormattedTotalResults string `json:"formattedTotalResults"`
} `json:"searchInformation"`
Items []ResultItem `json:"items"`
}
// ResultItem represents a specific search result from a Google Custom Search API call.
type ResultItem struct {
Kind string `json:"kind"`
Title string `json:"title"`
HTMLTitle string `json:"htmlTitle"`
Link string `json:"link"`
DisplayLink string `json:"displayLink"`
Snippet string `json:"snippet"`
HTMLSnippet string `json:"htmlSnippet"`
CacheID string `json:"cacheId"`
FormattedURL string `json:"formattedUrl"`
HTMLFormattedURL string `json:"htmlFormattedUrl"`
Pagemap struct {
CseThumbnail []struct {
Width string `json:"width"`
Height string `json:"height"`
Src string `json:"src"`
} `json:"cse_thumbnail"`
Metatags []struct {
Viewport string `json:"viewport"`
OgTitle string `json:"og:title"`
OgSiteName string `json:"og:site_name"`
OgDescription string `json:"og:description"`
OgImage string `json:"og:image"`
MsapplicationTilecolor string `json:"msapplication-tilecolor"`
MsapplicationTileimage string `json:"msapplication-tileimage"`
} `json:"metatags"`
CseImage []struct {
Src string `json:"src"`
} `json:"cse_image"`
} `json:"pagemap,omitempty"`
Mime string `json:"mime,omitempty"`
FileFormat string `json:"fileFormat,omitempty"`
}