Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gpahal/head
A go library for parsing information in a HTML head tag
https://github.com/gpahal/head
go golang head html html-head metadata opengraph opengraph-tags
Last synced: 1 day ago
JSON representation
A go library for parsing information in a HTML head tag
- Host: GitHub
- URL: https://github.com/gpahal/head
- Owner: gpahal
- License: mit
- Created: 2020-06-16T09:51:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-22T05:33:57.000Z (over 1 year ago)
- Last Synced: 2024-12-21T02:43:30.032Z (4 days ago)
- Topics: go, golang, head, html, html-head, metadata, opengraph, opengraph-tags
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# head
[![GoDoc](https://godoc.org/github.com/gpahal/head?status.svg)](https://godoc.org/github.com/gpahal/head)
A go library for parsing information in a HTML head tag.
## Installation
```sh
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.```go
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.```go
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](https://godoc.org/github.com/gpahal/head).## License
Licensed under MIT license ([LICENSE](LICENSE) or [opensource.org/licenses/MIT](https://opensource.org/licenses/MIT))