Documentation
¶
Index ¶
- Constants
- Variables
- func Compare(first, second core.Type) int64
- func IsScreenshotFormatValid(format string) bool
- func WithContext(ctx context.Context, drv Driver, opts ...Option) context.Context
- func WithDefaultTimeout(ctx context.Context) (context.Context, context.CancelFunc)
- type Driver
- type HTMLDocument
- type HTMLElement
- type HTMLNode
- type HTTPCookie
- func (c HTTPCookie) Compare(other core.Value) int64
- func (c HTTPCookie) Copy() core.Value
- func (c HTTPCookie) GetIn(_ context.Context, path []core.Value) (core.Value, error)
- func (c HTTPCookie) Hash() uint64
- func (c HTTPCookie) MarshalJSON() ([]byte, error)
- func (c HTTPCookie) String() string
- func (c HTTPCookie) Type() core.Type
- func (c HTTPCookie) Unwrap() interface{}
- type HTTPHeader
- func (h HTTPHeader) Compare(other core.Value) int64
- func (h HTTPHeader) Copy() core.Value
- func (h HTTPHeader) Get(key string) string
- func (h HTTPHeader) GetIn(_ context.Context, path []core.Value) (core.Value, error)
- func (h HTTPHeader) Hash() uint64
- func (h HTTPHeader) MarshalJSON() ([]byte, error)
- func (h HTTPHeader) Set(key, value string)
- func (h HTTPHeader) String() string
- func (h HTTPHeader) Type() core.Type
- func (h HTTPHeader) Unwrap() interface{}
- type LoadDocumentParams
- type Option
- type PDFParams
- type SameSite
- type ScreenshotFormat
- type ScreenshotParams
- type WaitEvent
Constants ¶
View Source
const ( // Event indicating to wait for value to appear WaitEventPresence = 0 // Event indicating to wait for value to disappear WaitEventAbsence = 1 )
View Source
const DefaultTimeout = time.Second * 30
Variables ¶
Functions ¶
func IsScreenshotFormatValid ¶ added in v0.7.0
func WithContext ¶ added in v0.7.0
func WithDefaultTimeout ¶ added in v0.7.0
Types ¶
type Driver ¶ added in v0.7.0
type Driver interface {
io.Closer
Name() string
LoadDocument(ctx context.Context, params LoadDocumentParams) (HTMLDocument, error)
}
type HTMLDocument ¶ added in v0.7.0
type HTMLDocument interface {
HTMLNode
DocumentElement() HTMLElement
GetURL() core.Value
SetURL(ctx context.Context, url values.String) error
GetCookies(ctx context.Context) (*values.Array, error)
SetCookies(ctx context.Context, cookies ...HTTPCookie) error
DeleteCookies(ctx context.Context, cookies ...HTTPCookie) error
ClickBySelector(ctx context.Context, selector values.String) (values.Boolean, error)
ClickBySelectorAll(ctx context.Context, selector values.String) (values.Boolean, error)
InputBySelector(ctx context.Context, selector values.String, value core.Value, delay values.Int) (values.Boolean, error)
SelectBySelector(ctx context.Context, selector values.String, value *values.Array) (*values.Array, error)
PrintToPDF(ctx context.Context, params PDFParams) (values.Binary, error)
CaptureScreenshot(ctx context.Context, params ScreenshotParams) (values.Binary, error)
ScrollTop(ctx context.Context) error
ScrollBottom(ctx context.Context) error
ScrollBySelector(ctx context.Context, selector values.String) error
ScrollByXY(ctx context.Context, x, y values.Float) error
MoveMouseByXY(ctx context.Context, x, y values.Float) error
MoveMouseBySelector(ctx context.Context, selector values.String) error
WaitForElement(ctx context.Context, selector values.String, when WaitEvent) error
WaitForAttributeBySelector(ctx context.Context, selector, name values.String, value core.Value, when WaitEvent) error
WaitForAttributeBySelectorAll(ctx context.Context, selector, name values.String, value core.Value, when WaitEvent) error
WaitForStyleBySelector(ctx context.Context, selector, name values.String, value core.Value, when WaitEvent) error
WaitForStyleBySelectorAll(ctx context.Context, selector, name values.String, value core.Value, when WaitEvent) error
WaitForClassBySelector(ctx context.Context, selector, class values.String, when WaitEvent) error
WaitForClassBySelectorAll(ctx context.Context, selector, class values.String, when WaitEvent) error
}
The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.
type HTMLElement ¶ added in v0.7.0
type HTMLElement interface {
HTMLNode
InnerText(ctx context.Context) values.String
InnerHTML(ctx context.Context) values.String
GetValue(ctx context.Context) core.Value
SetValue(ctx context.Context, value core.Value) error
GetStyles(ctx context.Context) (*values.Object, error)
GetStyle(ctx context.Context, name values.String) (core.Value, error)
SetStyles(ctx context.Context, values *values.Object) error
SetStyle(ctx context.Context, name values.String, value core.Value) error
RemoveStyle(ctx context.Context, name ...values.String) error
GetAttributes(ctx context.Context) *values.Object
GetAttribute(ctx context.Context, name values.String) core.Value
SetAttributes(ctx context.Context, values *values.Object) error
SetAttribute(ctx context.Context, name, value values.String) error
RemoveAttribute(ctx context.Context, name ...values.String) error
InnerHTMLBySelector(ctx context.Context, selector values.String) values.String
InnerHTMLBySelectorAll(ctx context.Context, selector values.String) *values.Array
InnerTextBySelector(ctx context.Context, selector values.String) values.String
InnerTextBySelectorAll(ctx context.Context, selector values.String) *values.Array
Click(ctx context.Context) (values.Boolean, error)
Input(ctx context.Context, value core.Value, delay values.Int) error
Select(ctx context.Context, value *values.Array) (*values.Array, error)
ScrollIntoView(ctx context.Context) error
Hover(ctx context.Context) error
WaitForAttribute(ctx context.Context, name values.String, value core.Value, when WaitEvent) error
WaitForStyle(ctx context.Context, name values.String, value core.Value, when WaitEvent) error
WaitForClass(ctx context.Context, class values.String, when WaitEvent) error
}
HTMLElement is the most general base interface which most objects in a Document implement.
type HTMLNode ¶ added in v0.7.0
type HTMLNode interface {
core.Value
core.Iterable
core.Getter
core.Setter
collections.Measurable
io.Closer
NodeType() values.Int
NodeName() values.String
GetChildNodes(ctx context.Context) core.Value
GetChildNode(ctx context.Context, idx values.Int) core.Value
QuerySelector(ctx context.Context, selector values.String) core.Value
QuerySelectorAll(ctx context.Context, selector values.String) core.Value
CountBySelector(ctx context.Context, selector values.String) values.Int
ExistsBySelector(ctx context.Context, selector values.String) values.Boolean
}
Node is an interface from which a number of DOM API object types inherit. It allows those types to be treated similarly; for example, inheriting the same set of methods, or being tested in the same way.
type HTTPCookie ¶ added in v0.7.0
type HTTPCookie struct {
Name string
Value string
Path string
Domain string
Expires time.Time
MaxAge int
Secure bool
HTTPOnly bool
SameSite SameSite
}
HTTPCookie HTTPCookie object
func (HTTPCookie) Copy ¶ added in v0.7.0
func (c HTTPCookie) Copy() core.Value
func (HTTPCookie) Hash ¶ added in v0.7.0
func (c HTTPCookie) Hash() uint64
func (HTTPCookie) MarshalJSON ¶ added in v0.7.0
func (c HTTPCookie) MarshalJSON() ([]byte, error)
func (HTTPCookie) String ¶ added in v0.7.0
func (c HTTPCookie) String() string
func (HTTPCookie) Type ¶ added in v0.7.0
func (c HTTPCookie) Type() core.Type
func (HTTPCookie) Unwrap ¶ added in v0.7.0
func (c HTTPCookie) Unwrap() interface{}
type HTTPHeader ¶ added in v0.7.0
HTTPCookie HTTPCookie object
func (HTTPHeader) Copy ¶ added in v0.7.0
func (h HTTPHeader) Copy() core.Value
func (HTTPHeader) Get ¶ added in v0.7.0
func (h HTTPHeader) Get(key string) string
func (HTTPHeader) Hash ¶ added in v0.7.0
func (h HTTPHeader) Hash() uint64
func (HTTPHeader) MarshalJSON ¶ added in v0.7.0
func (h HTTPHeader) MarshalJSON() ([]byte, error)
func (HTTPHeader) Set ¶ added in v0.7.0
func (h HTTPHeader) Set(key, value string)
func (HTTPHeader) String ¶ added in v0.7.0
func (h HTTPHeader) String() string
func (HTTPHeader) Type ¶ added in v0.7.0
func (h HTTPHeader) Type() core.Type
func (HTTPHeader) Unwrap ¶ added in v0.7.0
func (h HTTPHeader) Unwrap() interface{}
type LoadDocumentParams ¶ added in v0.7.0
type LoadDocumentParams struct {
URL string
UserAgent string
KeepCookies bool
Cookies []HTTPCookie
Header HTTPHeader
}
type PDFParams ¶ added in v0.7.0
type PDFParams struct {
// Paper orientation. Defaults to false.
Landscape values.Boolean
DisplayHeaderFooter values.Boolean
// Print background graphics. Defaults to false.
PrintBackground values.Boolean
// Scale of the webpage rendering. Defaults to 1.
Scale values.Float
// Paper width in inches. Defaults to 8.5 inches.
PaperWidth values.Float
// Paper height in inches. Defaults to 11 inches.
PaperHeight values.Float
// Top margin in inches. Defaults to 1cm (~0.4 inches).
MarginTop values.Float
// Bottom margin in inches. Defaults to 1cm (~0.4 inches).
MarginBottom values.Float
// Left margin in inches. Defaults to 1cm (~0.4 inches).
MarginLeft values.Float
// Right margin in inches. Defaults to 1cm (~0.4 inches).
MarginRight values.Float
// Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
PageRanges values.String
// Whether to silently ignore invalid but successfully parsed page ranges, such as '3-2'. Defaults to false.
IgnoreInvalidPageRanges values.Boolean
// HTML template for the print values. Should be valid HTML markup with following classes used to inject printing values into them: - `date`: formatted print date - `title`: document title - `url`: document location - `pageNumber`: current page number - `totalPages`: total pages in the document
// For example, `<span class=title></span>` would generate span containing the title.
HeaderTemplate values.String
FooterTemplate values.String
// Whether or not to prefer page size as defined by css.
// Defaults to false, in which case the content will be scaled to fit the paper size.
PreferCSSPageSize values.Boolean
}
PDFParams represents the arguments for PrintToPDF function.
func NewDefaultHTMLPDFParams ¶ added in v0.7.0
func NewDefaultHTMLPDFParams() PDFParams
type ScreenshotFormat ¶ added in v0.7.0
type ScreenshotFormat string
const ( ScreenshotFormatPNG ScreenshotFormat = "png" ScreenshotFormatJPEG ScreenshotFormat = "jpeg" )
type ScreenshotParams ¶ added in v0.7.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.