add another method to get html document

This commit is contained in:
tesla.peng
2013-07-24 18:29:10 +08:00
parent 8a4ef5dbdd
commit 2d2b626f0d
+8
View File
@@ -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