-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsearch.go
65 lines (56 loc) · 1.35 KB
/
search.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
// Package googlesearch launch search queries on google.
package googlesearch
// Defaults provides default search settings.
//
var Defaults = Config{
TLD: "com", // google.COM
Lang: "en", // in ENglish
Safe: "off", // and NSFW.
CodesetInput: "utf-8", // input charset format.
CodesetOutput: "utf-8", // output charset format.
NbResults: 10, // Number of answers per query.
SearchURL: "https://www.google.%s/search", // Base url.
}
// Config defines a search settings.
//
type Config struct {
TLD string
Lang string
Safe string
SearchURL string
CodesetInput string
CodesetOutput string
NbResults int
}
// List represents a list of SearchResult.
//
type List []SearchResult
// SearchResult defines a single search result website.
//
type SearchResult struct {
Name string
Desc string
Link string
}
// GetName gets the result description.
//
func (res *SearchResult) GetName() string {
return res.Name
}
// GetDescription gets the result description.
//
func (res *SearchResult) GetDescription() string {
return res.Desc
}
// GetLink gets the result link location.
//
func (res *SearchResult) GetLink() string {
return res.Link
}
// Resulter represents the result get data interface.
//
type Resulter interface {
GetName() string
GetDescription() string
GetLink() string
}