htmlinfo

package
v0.0.0-...-011af71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTMLInfo

type HTMLInfo struct {

	// http.Client instance to use, if nil then will be used default client
	Client *http.Client `json:"-"`
	// If it's true then parser will fetch oembed data from oembed url if possible
	AllowOembedFetching bool `json:"-"`
	// If is' true parser will extract main page content from html
	AllowMainContentExtraction bool `json:"-"`

	Title         string `json:"title"`
	Description   string `json:"description"`
	CanonicalURL  string `json:"canonical_url"`
	OembedJSONURL string `json:"oembed_json_url"`
	OembedXMLURL  string `json:"oembed_xml_url"`
	FaviconURL    string `json:"favicon_url"`
	ImageSrcURL   string `json:"image_src_url"`
	// Readability package is being used inside
	MainContent string               `json:"main_content"`
	OGInfo      *opengraph.OpenGraph `json:"opengraph"`
	OembedInfo  *oembed.Info         `json:"oembed"`
	// contains filtered or unexported fields
}

HTMLInfo contains information extracted from HTML page

func NewHTMLInfo

func NewHTMLInfo() *HTMLInfo

NewHTMLInfo return new instance of HTMLInfo

func (*HTMLInfo) GenerateOembedFor

func (info *HTMLInfo) GenerateOembedFor(pageURL string) *oembed.Info

GenerateOembedFor return Oembed Info for given url based on previously parsed data The returned oembed data is also updated in info.OembedInfo Example:

info := NewHTMLInfo() info.Parse(dataReader, &sourceURL) oembed := info.GenerateOembedFor(sourceURL)

func (*HTMLInfo) Parse

func (info *HTMLInfo) Parse(s io.Reader, pageURL *string, contentType *string) error

Parse return information about page @param s - contains page source @params pageURL - contains URL from where the data was taken [optional] @params contentType - contains Content-Type header value [optional] if no url is given then parser won't attempt to parse oembed info

func (*HTMLInfo) String

func (info *HTMLInfo) String() string

func (*HTMLInfo) ToJSON

func (info *HTMLInfo) ToJSON() ([]byte, error)

ToJSON return json represenation of structure, simple wrapper around json package

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL