Documentation ¶
Overview ¶
Package metaextractor will extract the title, description, OG & meta tags from HTML
If you have any suggestions or comments, please feel free to open an issue on this GitHub repository!
By MrZ (https://github.com/mrz1836)
Index ¶
Examples ¶
Constants ¶
View Source
const ( TagBody = "body" TagContent = "content" TagMeta = "meta" TagMetaAuthor = "author" TagMetaDescription = "description" TagName = "name" TagOGAuthor = "og:author" TagOGDescription = "og:description" TagOGImage = "og:image" TagOGPublisher = "og:publisher" TagOGSiteName = "og:site_name" TagOGTitle = "og:title" TagProperty = "property" TagTitle = "title" TagTwitterCard = "twitter:card" TagTwitterDescription = "twitter:description" TagTwitterImage = "twitter:image" TagTwitterPlayer = "twitter:player" TagTwitterPlayerHeight = "twitter:player:height" TagTwitterPlayerWidth = "twitter:player:width" TagTwitterTitle = "twitter:title" )
Tag and Property constants for parsing
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tags ¶
type Tags struct { Author string `json:"author"` Description string `json:"description"` OGAuthor string `json:"og_author"` OGDescription string `json:"og_description"` OGImage string `json:"og_image"` OGPublisher string `json:"og_publisher"` OGSiteName string `json:"og_site_name"` OGTitle string `json:"og_title"` Title string `json:"title"` TwitterDescription string `json:"twitter_description"` TwitterImage string `json:"twitter_image"` TwitterCard string `json:"twitter_card"` TwitterPlayer string `json:"twitter_player"` TwitterPlayerHeight string `json:"twitter_player_height"` TwitterPlayerWidth string `json:"twitter_player_width"` TwitterTitle string `json:"twitter_title"` }
Tags is the html/meta tags to extract and process
func Extract ¶
Extract is the method used to extract HTML tags
Example ¶
ExampleExtract will show an example using the extractor
// Set a client client := &http.Client{Timeout: 20 * time.Second} // Start the request req, err := http.NewRequestWithContext( context.Background(), http.MethodGet, "https://mrz1818.com", nil, ) if err != nil { log.Fatal(err) } // Fire the request var resp *http.Response if resp, err = client.Do(req); err != nil { log.Fatal(err) } // Close the body defer func() { _ = resp.Body.Close() }() // Extract the meta tags tags := Extract(resp.Body) fmt.Println(tags.Author)
Output: MrZ, Proof of Work LLC
Click to show internal directories.
Click to hide internal directories.