Documentation
¶
Overview ¶
Metadata package is a set of tools to parse HTML pages to extract their metadata.
For now, the following set of metadata specifications are supported:
- HTML 5 + RDFa
- Dublin Core. Dublin Core metadata are defined here: http://www.dublincore.org/documents/dces/
- Open Graph. Open Graph metadata (Facebook) are defined here: http://ogp.me/
- Twitter. Twitter metadata are defined here: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Page ¶
type Page struct { Lang string `json:"lang,omitempty"` Properties Properties `json:"properties,omitempty"` // contains filtered or unexported fields }
Page is structure holding HTML page metadata.
func ReadPage ¶
ReadPage is use to extract metadata from an HTML page. It returns a Page struct for easy manipulation of those metadata.
Example ¶
package main import ( "fmt" "strings" "github.com/processone/dpk/pkg/metadata" ) func main() { html := `<!DOCTYPE html> <html lang="en"> <head prefix="og: http://ogp.me/ns#"> <meta charset="utf-8"/> <meta property="og:title" content="Open Graph title" /> </head> <body><p>This is a test page</p></body> </html>` if page, err := metadata.ReadPage(strings.NewReader(html)); err != nil { fmt.Println(page.Title()) } }
Output: Open Graph title
type Properties ¶
Properties is a map gathering HTML page metadata properties.
Click to show internal directories.
Click to hide internal directories.