diff --git a/type.go b/type.go index 29b2941..fa8f482 100644 --- a/type.go +++ b/type.go @@ -32,6 +32,14 @@ func NewDocument(url string) (d *Document, e error) { if e != nil { return } + return NewDocumentWithHttpResponse(res) +} + +// NewDocumentWithHttpResponse() is another Document constructor that takes a http resonse as argument. +// If you want to get some page which need be authorized,this method may be helpful +// It loads the specified document, parses it, and stores the root Document +// node, ready to be manipulated. +func NewDocumentWithHttpResponse(res *http.Response) (d *Document, e error) { defer res.Body.Close() // Parse the HTML into nodes