From 2d2b626f0d431b99a176da9b357c62abdf46e536 Mon Sep 17 00:00:00 2001 From: "tesla.peng" Date: Wed, 24 Jul 2013 18:29:10 +0800 Subject: [PATCH] add another method to get html document --- type.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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