screenshot

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2019 License: MIT Imports: 21 Imported by: 0

README

Golang library for creating website screenshots using Chrome CDP

CDP: Chrome 67+

Pkg-Deps on debian-8: libasound2 libatk-bridge2.0-0 libgtk-3-0 libnss3 libx11-xcb-dev libxss1 libxtst6

URLs to test:

GoModulesTutorial:

Examples:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFreePort

func GetFreePort() (int, error)

GetFreePort - returns free TCP port.

Types

type Config

type Config struct {
	CMD  string
	Host string

	URL            string
	AcceptLanguage string
	UserAgent      string
	ProfileDir     string

	FullPage bool
	IsJPEG   bool

	RandomProfileDir bool

	Port int

	WindowWidth int
	WindowHight int

	PaddingTop    int
	PaddingBottom int
	PaddingLeft   int
	PaddingRight  int

	JpegQuality int

	Wait     time.Duration
	Deadline time.Duration
}

Config - options for URL screenshot function.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig - creates structure with default values.

func (*Config) CDPScreenshot

func (c *Config) CDPScreenshot(ctx context.Context) ([]byte, error)

CDPScreenshot - low-level function that creates screenshot for URL using CDP.

func (*Config) KillByPgidAndCleanup

func (c *Config) KillByPgidAndCleanup(cmd *exec.Cmd)

KillByPgidAndCleanup - kills CDP process and remove randomly created profile directory.

func (*Config) Screenshot

func (c *Config) Screenshot() ([]byte, error)

Screenshot - makes screenshot for URL, returns base64 encoded slice bytes and raw slice bytes.

Jump to

Keyboard shortcuts

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