webpage

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache added in v0.6.0

type Cache struct {
	// contains filtered or unexported fields
}

Cache is cache data for Web page informations.

func NewCache added in v0.6.0

func NewCache(dir string) (*Cache, error)

NewCache function creates Cache instance and import cache data.

func (*Cache) Get added in v0.6.0

func (c *Cache) Get(s string) *Info

Get method gets Web page data from cache.

func (*Cache) Put added in v0.6.0

func (c *Cache) Put(i *Info)

Put method puts Web page data to cache.

func (*Cache) PutURL added in v0.6.0

func (c *Cache) PutURL(ctx context.Context, urlStr string) (*Info, error)

PutURL reads Web page data from URL and puts to cache.

func (*Cache) Remove added in v0.6.0

func (c *Cache) Remove()

Remove method removes cache file.

func (*Cache) Save added in v0.6.0

func (c *Cache) Save() error

Save method saves data to cache file.

type Info

type Info struct {
	URL         string `json:"url,omitempty"`
	Location    string `json:"location,omitempty"`
	Canonical   string `json:"canonical,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	ImageURL    string `json:"image_url,omitempty"`
}

func ReadPage

func ReadPage(ctx context.Context, urlStr string) (*Info, error)

ReadPage function reads web page from URL, and analysis information.

func (*Info) Encode added in v0.6.0

func (i *Info) Encode(w io.Writer) error

Encode putputs to io.Writer by JSON format.

func (*Info) ImageFile added in v0.6.0

func (i *Info) ImageFile(ctx context.Context, dir string) (string, error)

Jump to

Keyboard shortcuts

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