All checks were successful
Golang test / go-test (push) Successful in 1m9s
28 lines
587 B
Go
28 lines
587 B
Go
package request
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
"golang.org/x/net/html"
|
|
)
|
|
|
|
func HTML[T InputUrl](urlInput T, opt *Options) (node *html.Node, res *http.Response, err error) {
|
|
if res, err = Request(urlInput, opt); err != nil {
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
node, err = html.Parse(res.Body)
|
|
return
|
|
}
|
|
|
|
func Goquery[T InputUrl](urlInput T, opt *Options) (doc *goquery.Document, res *http.Response, err error) {
|
|
node, res, err := HTML(urlInput, opt)
|
|
if err != nil {
|
|
return
|
|
}
|
|
doc = goquery.NewDocumentFromNode(node)
|
|
doc.Url = res.Request.URL
|
|
return
|
|
}
|