Exporting data all types support added.

This commit is contained in:
Musab Gültekin 2019-06-09 13:22:20 +03:00
parent d967555b62
commit 9263877339
4 changed files with 7 additions and 4 deletions

View File

@ -23,6 +23,8 @@ func Export(response *Response) {
for res := range response.Exports {
//fmt.Println(res)
_ = json.NewEncoder(file).Encode(res)
encoder := json.NewEncoder(file)
encoder.SetEscapeHTML(false)
encoder.Encode(res)
}
}

View File

@ -148,7 +148,7 @@ func (g *Geziyor) Do(req *http.Request) {
Body: body,
Doc: doc,
Geziyor: g,
Exports: make(chan map[string]interface{}, 1),
Exports: make(chan interface{}, 1),
}
// Export Function

View File

@ -22,7 +22,8 @@ func TestGeziyor_IP(t *testing.T) {
StartURLs: []string{"http://api.ipify.org"},
Cache: httpcache.NewMemoryCache(),
ParseFunc: func(r *geziyor.Response) {
fmt.Println(string(r.Body))
fmt.Println(r.Doc.Text())
r.Exports <- r.Doc.Text()
r.Geziyor.Get("http://api.ipify.org")
},
})

View File

@ -14,7 +14,7 @@ type Response struct {
Doc *goquery.Document
Geziyor *Geziyor
Exports chan map[string]interface{}
Exports chan interface{}
}
// JoinURL joins base response URL and provided relative URL.