Options refactored to its own file. Timeout increased to 60 sec
This commit is contained in:
@ -20,9 +20,6 @@ geziyor := NewGeziyor(Opt{
|
|||||||
r.Exports <- map[string]interface{}{
|
r.Exports <- map[string]interface{}{
|
||||||
"text": s.Find("span.text").Text(),
|
"text": s.Find("span.text").Text(),
|
||||||
"author": s.Find("small.author").Text(),
|
"author": s.Find("small.author").Text(),
|
||||||
"tags": s.Find("div.tags > a.tag").Map(func(_ int, s *goquery.Selection) string {
|
|
||||||
return s.Text()
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
10
geziyor.go
10
geziyor.go
@ -23,14 +23,6 @@ type Geziyor struct {
|
|||||||
visitedURLS []string
|
visitedURLS []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options is custom options type for Geziyor
|
|
||||||
type Options struct {
|
|
||||||
AllowedDomains []string
|
|
||||||
StartURLs []string
|
|
||||||
ParseFunc func(response *Response)
|
|
||||||
Cache httpcache.Cache
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
}
|
}
|
||||||
@ -40,7 +32,7 @@ func init() {
|
|||||||
func NewGeziyor(opt Options) *Geziyor {
|
func NewGeziyor(opt Options) *Geziyor {
|
||||||
geziyor := &Geziyor{
|
geziyor := &Geziyor{
|
||||||
client: &http.Client{
|
client: &http.Client{
|
||||||
Timeout: time.Second * 10,
|
Timeout: time.Second * 60,
|
||||||
},
|
},
|
||||||
opt: opt,
|
opt: opt,
|
||||||
}
|
}
|
||||||
|
21
options.go
Normal file
21
options.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package geziyor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/fpfeng/httpcache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Options is custom options type for Geziyor
|
||||||
|
type Options struct {
|
||||||
|
// AllowedDomains is domains that are allowed to make requests
|
||||||
|
// If empty, any domain is allowed
|
||||||
|
AllowedDomains []string
|
||||||
|
// First requests will made to this url array. (Concurrently)
|
||||||
|
StartURLs []string
|
||||||
|
// ParseFunc is callback of StartURLs response.
|
||||||
|
ParseFunc func(response *Response)
|
||||||
|
|
||||||
|
// Set this to enable caching responses.
|
||||||
|
// Memory Cache: httpcache.NewMemoryCache()
|
||||||
|
// Disk Cache: diskcache.New(".cache")
|
||||||
|
Cache httpcache.Cache
|
||||||
|
}
|
Reference in New Issue
Block a user