htmlinfo

package
v0.0.0-...-d9417c7 Latest Latest
Warning

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

Go to latest
Published: May 17, 2018 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 it's true parser will extract main page content from html
	AllowMainContentExtraction bool `json:"-"`
	// We'll forward it to Oembed' fetchOembed method
	AcceptLanguage string `json:"-"`

	Title         string       `json:"title"`
	Description   string       `json:"description"`
	AuthorName    string       `json:"author_name"`
	CanonicalURL  string       `json:"canonical_url"`
	OembedJSONURL string       `json:"oembed_json_url"`
	OembedXMLURL  string       `json:"oembed_xml_url"`
	FaviconURL    string       `json:"favicon_url"`
	TouchIcons    []*TouchIcon `json:"touch_icons"`
	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

type TouchIcon

type TouchIcon struct {
	URL        string `json:"url"`
	Type       string `json:"type"`
	Width      uint64 `json:"width"`
	Height     uint64 `json:"height"`
	IsScalable bool   `json:"is_scalable"`
}

TouchIcon contains all icons parsed from page header, including Apple touch icons

Jump to

Keyboard shortcuts

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