Skip to content

Commit

Permalink
add MetaDescription; update UA
Browse files Browse the repository at this point in the history
  • Loading branch information
denisskin committed Sep 5, 2018
1 parent ef3fa1a commit 51f64e7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion document.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var DefaultHeader = http.Header{
"Accept-Encoding": {"gzip, deflate"},
"Cache-Control": {"max-age=0"},
"Connection": {"keep-alive"},
"User-Agent": {"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"},
"User-Agent": {"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"},
}

var DefaultClient *http.Client
Expand Down Expand Up @@ -524,6 +524,14 @@ func (d *Document) MetaTags() HTMLElements {
return d.GetElementsByTagName("meta")
}

// MetaDescription gets html-document description from <meta name="description">
func (d *Document) MetaDescription() string {
if e := d.MetaTags().FilterByAttrValue("name", "description").First(); e != nil {
return e.Attributes["content"]
}
return ""
}

// MetaIcon gets image-url from meta-info for html-document
func (d *Document) MetaIcon() string {
linkTags := d.GetElementsByTagName("link").FilterByAttr("href")
Expand Down

0 comments on commit 51f64e7

Please sign in to comment.