aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/PuerkitoBio/goquery/type.go
diff options
context:
space:
mode:
authorale <ale@incal.net>2018-08-31 08:28:51 +0100
committerale <ale@incal.net>2018-08-31 08:28:51 +0100
commitb3d419486a87c9193c2fd6c16168f600876e0f73 (patch)
tree849d1333d4fac8e5654e65a0fdf4b2cb00355ab9 /vendor/github.com/PuerkitoBio/goquery/type.go
parent86a0bd2d15a07662fdae4e24589b08706c2e80b9 (diff)
downloadcrawl-b3d419486a87c9193c2fd6c16168f600876e0f73.tar.gz
crawl-b3d419486a87c9193c2fd6c16168f600876e0f73.zip
Update dependencies
Diffstat (limited to 'vendor/github.com/PuerkitoBio/goquery/type.go')
-rw-r--r--vendor/github.com/PuerkitoBio/goquery/type.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/vendor/github.com/PuerkitoBio/goquery/type.go b/vendor/github.com/PuerkitoBio/goquery/type.go
index e2169fa..6ad51db 100644
--- a/vendor/github.com/PuerkitoBio/goquery/type.go
+++ b/vendor/github.com/PuerkitoBio/goquery/type.go
@@ -31,6 +31,10 @@ func NewDocumentFromNode(root *html.Node) *Document {
// NewDocument is a Document constructor that takes a string URL as argument.
// It loads the specified document, parses it, and stores the root Document
// node, ready to be manipulated.
+//
+// Deprecated: Use the net/http standard library package to make the request
+// and validate the response before calling goquery.NewDocumentFromReader
+// with the response's body.
func NewDocument(url string) (*Document, error) {
// Load the URL
res, e := http.Get(url)
@@ -40,10 +44,10 @@ func NewDocument(url string) (*Document, error) {
return NewDocumentFromResponse(res)
}
-// NewDocumentFromReader returns a Document from a generic reader.
+// NewDocumentFromReader returns a Document from an io.Reader.
// It returns an error as second value if the reader's data cannot be parsed
-// as html. It does *not* check if the reader is also an io.Closer, so the
-// provided reader is never closed by this call, it is the responsibility
+// as html. It does not check if the reader is also an io.Closer, the
+// provided reader is never closed by this call. It is the responsibility
// of the caller to close it if required.
func NewDocumentFromReader(r io.Reader) (*Document, error) {
root, e := html.Parse(r)
@@ -56,6 +60,8 @@ func NewDocumentFromReader(r io.Reader) (*Document, error) {
// NewDocumentFromResponse is another Document constructor that takes an http response as argument.
// It loads the specified response's document, parses it, and stores the root Document
// node, ready to be manipulated. The response's body is closed on return.
+//
+// Deprecated: Use goquery.NewDocumentFromReader with the response's body.
func NewDocumentFromResponse(res *http.Response) (*Document, error) {
if res == nil {
return nil, errors.New("Response is nil")