Skip to content
/ head Public

A go library for parsing information in a HTML head tag

License

Notifications You must be signed in to change notification settings

gpahal/head

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

head

GoDoc

A go library for parsing information in a HTML head tag.

Installation

go get github.com/gpahal/head

Usage

Processing a URL

The head.ProcessURL function takes a url string and a *http.Client, makes a GET request to the url using the http client and returns a new *head.Object from the returned HTML. If client is nil, a default client is used.

object, err := head.ProcessURL("http://ogp.me", nil)

Parsing HTML

The head.ParseHTML function takes an io.Reader, reads HTML, parses the HTML and returns a new *head.Object.

resp, _ := http.Get("http://ogp.me")
// ignoring the error and other response attributes (like status code)
// for simplicity
defer resp.Body.Close()

object, err := head.ParseHTML(resp.Body)

Documentation

The complete API documentation is available on GoDoc.

License

Licensed under MIT license (LICENSE or opensource.org/licenses/MIT)