commit
ba5b2e3aec
|
@ -18,6 +18,12 @@ const (
|
|||
intextTag = "intext:"
|
||||
operatorOr = "|"
|
||||
operatorAnd = "+"
|
||||
bookTag = "book:"
|
||||
ipTag = "ip:"
|
||||
mapsTag = "maps:"
|
||||
allintextTag = "allintext:"
|
||||
infoTag = "info:"
|
||||
inanchorTag = "inanchor:"
|
||||
)
|
||||
|
||||
// GoogleSearch is the Google search implementation for Dorkgen
|
||||
|
@ -139,3 +145,33 @@ func (e *GoogleSearch) Plain(value string) *GoogleSearch {
|
|||
e.tags = append(e.tags, value)
|
||||
return e
|
||||
}
|
||||
|
||||
// Book searches for book titles related to keywords.
|
||||
func (e *GoogleSearch) Book(keyword string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.join(bookTag, keyword, true))
|
||||
return e
|
||||
}
|
||||
|
||||
// Maps searches for maps related to keywords.
|
||||
func (e *GoogleSearch) Maps(location string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.join(mapsTag, location, false))
|
||||
return e
|
||||
}
|
||||
|
||||
// AllInText searches text of page.
|
||||
func (e *GoogleSearch) AllInText(text string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.join(allintextTag, text, true))
|
||||
return e
|
||||
}
|
||||
|
||||
// Info presents some information that Google has about a web page, including similar pages, the cached version of the page, and sites linking to the page.
|
||||
func (e *GoogleSearch) Info(url string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.join(infoTag, url, true))
|
||||
return e
|
||||
}
|
||||
|
||||
// InAnchor search link anchor text.
|
||||
func (e *GoogleSearch) InAnchor(text string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.join(inanchorTag, text, true))
|
||||
return e
|
||||
}
|
||||
|
|
|
@ -175,4 +175,54 @@ func TestInit(t *testing.T) {
|
|||
"q": []string{"site:linkedin.com (intext:\"1\" | intext:\"2\") intitle:\"jordan\""},
|
||||
}, result, "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should use book tag", func(t *testing.T) {
|
||||
dork = googlesearch.New()
|
||||
|
||||
result := dork.
|
||||
Book("test").
|
||||
String()
|
||||
|
||||
assert.Equal("book:\"test\"", result, "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should use maps tag", func(t *testing.T) {
|
||||
dork = googlesearch.New()
|
||||
|
||||
result := dork.
|
||||
Maps("france").
|
||||
String()
|
||||
|
||||
assert.Equal("maps:france", result, "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should use allintext tag", func(t *testing.T) {
|
||||
dork = googlesearch.New()
|
||||
|
||||
result := dork.
|
||||
AllInText("test").
|
||||
String()
|
||||
|
||||
assert.Equal("allintext:\"test\"", result, "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should use info tag", func(t *testing.T) {
|
||||
dork = googlesearch.New()
|
||||
|
||||
result := dork.
|
||||
Info("https://google.com/").
|
||||
String()
|
||||
|
||||
assert.Equal("info:\"https://google.com/\"", result, "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should use inanchor tag", func(t *testing.T) {
|
||||
dork = googlesearch.New()
|
||||
|
||||
result := dork.
|
||||
InAnchor("test").
|
||||
String()
|
||||
|
||||
assert.Equal("inanchor:\"test\"", result, "they should be equal")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue