Options used instead of direct parameter passing.
Tests updated.
This commit is contained in:
@ -2,25 +2,28 @@ package gezer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGezer_StartURLs_Simple(t *testing.T) {
|
||||
gezer := NewGezer(parse, "https://api.ipify.org", "https://api.ipify.org")
|
||||
gezer := NewGezer(Opt{
|
||||
StartURLs: []string{"https://api.ipify.org", "https://api.ipify.org"},
|
||||
ParseFunc: func(r *Response) {
|
||||
fmt.Println(string(r.Body))
|
||||
},
|
||||
})
|
||||
gezer.Start()
|
||||
}
|
||||
|
||||
func parse(response *Response) {
|
||||
fmt.Println(string(response.Body))
|
||||
func TestGezer_StartURLs_HTML(t *testing.T) {
|
||||
gezer := NewGezer(Opt{
|
||||
StartURLs: []string{"http://quotes.toscrape.com/"},
|
||||
ParseFunc: func(r *Response) {
|
||||
r.Doc.Find("div.quote").Each(func(i int, s *goquery.Selection) {
|
||||
fmt.Println(i, s.Find("span.text").Text(), s.Find("small.author").Text())
|
||||
})
|
||||
},
|
||||
})
|
||||
gezer.Start()
|
||||
}
|
||||
|
||||
//func TestGezer_StartURLs_HTML(t *testing.T) {
|
||||
// gezer := NewGezer(parse, "http://quotes.toscrape.com/")
|
||||
// gezer.Start()
|
||||
// for result := range gezer.Results {
|
||||
// result.Doc.Find("div.quote").Each(func(_ int, s *goquery.Selection) {
|
||||
// fmt.Println(s.Find("span.text").Text())
|
||||
// fmt.Println(s.Find("small.author").Text())
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
|
Reference in New Issue
Block a user