备份
This commit is contained in:
@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"golang.org/x/net/html"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@ -18,6 +19,9 @@ type Response struct {
|
||||
// Goquery Document object. If response IsHTML, its non-nil.
|
||||
HTMLDoc *goquery.Document
|
||||
|
||||
// xpath Document object. If response IsHTML, its non-nil.
|
||||
HTMLNode *html.Node
|
||||
|
||||
Request *Request
|
||||
}
|
||||
|
||||
@ -33,6 +37,15 @@ func (r *Response) JoinURL(relativeURL string) string {
|
||||
return joinedURL.String()
|
||||
}
|
||||
|
||||
// JoinURL2 joins base response URL and provided relative URL.
|
||||
func (r *Response) JoinURL2(relativeURL string) string {
|
||||
joinedURL, err := r.Request.URL.Parse(relativeURL)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return joinedURL.String()
|
||||
}
|
||||
|
||||
// IsHTML checks if response content is HTML by looking content-type header
|
||||
func (r *Response) IsHTML() bool {
|
||||
contentType := r.Header.Get("Content-Type")
|
||||
|
Reference in New Issue
Block a user