https://github.com/ammit/go-metaparser
Simple and elegant Metadata Parser in Go 🔥💬
https://github.com/ammit/go-metaparser
go golang metadata metadata-extraction opengraph parser scraper twitter-cards web-scraper
Last synced: 4 months ago
JSON representation
Simple and elegant Metadata Parser in Go 🔥💬
- Host: GitHub
- URL: https://github.com/ammit/go-metaparser
- Owner: ammit
- Created: 2020-04-16T20:55:25.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-20T06:22:48.000Z (about 6 years ago)
- Last Synced: 2025-12-18T14:42:53.213Z (6 months ago)
- Topics: go, golang, metadata, metadata-extraction, opengraph, parser, scraper, twitter-cards, web-scraper
- Language: Go
- Homepage:
- Size: 68.4 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.com/ammit/go-metaparser) [](https://goreportcard.com/report/github.com/ammit/go-metaparser)
# go-metaparser
> Lightweight metadata parser written in Go

With go-metaparser, you can easily extract structured meta-data from HTML. The purpose of this library is to be able to obtain all types of metadata from the web page.
Currently, it supports Open Graph, Twitter Card Metadata and some general metadata that doesn't belong to a particular type, for example - title, description etc.
## Installation
Install the package with:
```go
go get github.com/ammit/go-metaparser
```
Import it with:
```go
import "github.com/ammit/go-metaparser"
```
and use parser as the package name inside the code.
## Usage example
Please check the example folder for details.
```go
package main
import (
"fmt"
parser "github.com/ammit/go-metaparser"
)
const (
url = "http://ogp.me"
)
func main() {
p := parser.New()
b, err := p.FetchHTML(url)
if err != nil {
fmt.Printf("Could not fetch html from given url: %v \n", url)
}
defer b.Close()
err = p.ParseHTML(b)
fmt.Printf("The parsed title is: %v \n", p.Title)
}
```
## Performance
You can run the benchmarks yourself, but here's the output on my machine:
```text
BenchmarkParser-12 19024 62147 ns/op 9858 B/op 261 allocs/op
```
## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request :)