Skip to content

tiendc/go-linkpreview

Repository files navigation

Go Version GoDoc GoReport

Link preview and site info scraping library for Go

Installation

go get github.com/tiendc/go-linkpreview

Usage

Simple one

    result, err := linkpreview.Parse(url)

    // Output:
    // {
    //   "title": <title>,
    //   "description": <description>,
    //   "og_meta": {<open graph metadata>},
    //   "twitter_meta": {<twitter metadata>},
    // }

Parse with configuration

    // Get everything
    result, err := linkpreview.Parse(url,
        linkpreview.ParseOGMeta(true),        // default: true
        linkpreview.ParseTwitterMeta(true),   // default: true
        linkpreview.ParseFavicons(true),      // default: false
        linkpreview.ReturnMetaTags(true),     // default: false
        linkpreview.ReturnLinkTags(true)      // default: false
    )

    // Output:
    // {
    //   "title": <title>,
    //   "description": <description>,
    //   "og_meta": {<open graph metadata>},
    //   "twitter_meta": {<twitter metadata>},
    //   "favicons": [],
    //   "meta_tags": [],
    //   "link_tags": [],
    // }

Contributing

  • You are welcome to make pull requests for new functions and bug fixes.

Authors

License

Releases

No releases published

Packages

No packages published