parent
24c5e7d522
commit
e60d1a5c4f
|
@ -6,18 +6,24 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
searchURL = "https://www.google.com/search"
|
||||
siteTag = "site:"
|
||||
urlTag = "inurl:"
|
||||
filetypeTag = "filetype:"
|
||||
cacheTag = "cache:"
|
||||
relatedTag = "related:"
|
||||
extTag = "ext:"
|
||||
excludeTag = "-"
|
||||
intitleTag = "intitle:"
|
||||
intextTag = "intext:"
|
||||
operatorOr = "|"
|
||||
operatorAnd = "+"
|
||||
searchURL = "https://www.google.com/search"
|
||||
siteTag = "site:"
|
||||
urlTag = "inurl:"
|
||||
filetypeTag = "filetype:"
|
||||
cacheTag = "cache:"
|
||||
relatedTag = "related:"
|
||||
extTag = "ext:"
|
||||
excludeTag = "-"
|
||||
intitleTag = "intitle:"
|
||||
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,39 @@ 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
|
||||
}
|
||||
|
||||
// IP finds sites hosted by a specific ip address.
|
||||
func (e *GoogleSearch) IP(address string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.join(ipTag, address, false))
|
||||
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,64 @@ 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 ip tag", func(t *testing.T) {
|
||||
dork = googlesearch.New()
|
||||
|
||||
result := dork.
|
||||
IP("172.217.19.238").
|
||||
String()
|
||||
|
||||
assert.Equal("ip:172.217.19.238", 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