Add cdp support for xpath scrapers (#625)

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
bnkai
2020-08-04 03:42:40 +03:00
committed by GitHub
parent 1b4a9eed36
commit 4373f9bf01
284 changed files with 133250 additions and 54 deletions

View File

@@ -0,0 +1,288 @@
// Package animation provides the Chrome DevTools Protocol
// commands, types, and events for the Animation domain.
//
// Generated by the cdproto-gen command.
package animation
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/runtime"
)
// DisableParams disables animation domain notifications.
type DisableParams struct{}
// Disable disables animation domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Animation.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// EnableParams enables animation domain notifications.
type EnableParams struct{}
// Enable enables animation domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Animation.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// GetCurrentTimeParams returns the current time of the an animation.
type GetCurrentTimeParams struct {
ID string `json:"id"` // Id of animation.
}
// GetCurrentTime returns the current time of the an animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-getCurrentTime
//
// parameters:
// id - Id of animation.
func GetCurrentTime(id string) *GetCurrentTimeParams {
return &GetCurrentTimeParams{
ID: id,
}
}
// GetCurrentTimeReturns return values.
type GetCurrentTimeReturns struct {
CurrentTime float64 `json:"currentTime,omitempty"` // Current time of the page.
}
// Do executes Animation.getCurrentTime against the provided context.
//
// returns:
// currentTime - Current time of the page.
func (p *GetCurrentTimeParams) Do(ctx context.Context) (currentTime float64, err error) {
// execute
var res GetCurrentTimeReturns
err = cdp.Execute(ctx, CommandGetCurrentTime, p, &res)
if err != nil {
return 0, err
}
return res.CurrentTime, nil
}
// GetPlaybackRateParams gets the playback rate of the document timeline.
type GetPlaybackRateParams struct{}
// GetPlaybackRate gets the playback rate of the document timeline.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-getPlaybackRate
func GetPlaybackRate() *GetPlaybackRateParams {
return &GetPlaybackRateParams{}
}
// GetPlaybackRateReturns return values.
type GetPlaybackRateReturns struct {
PlaybackRate float64 `json:"playbackRate,omitempty"` // Playback rate for animations on page.
}
// Do executes Animation.getPlaybackRate against the provided context.
//
// returns:
// playbackRate - Playback rate for animations on page.
func (p *GetPlaybackRateParams) Do(ctx context.Context) (playbackRate float64, err error) {
// execute
var res GetPlaybackRateReturns
err = cdp.Execute(ctx, CommandGetPlaybackRate, nil, &res)
if err != nil {
return 0, err
}
return res.PlaybackRate, nil
}
// ReleaseAnimationsParams releases a set of animations to no longer be
// manipulated.
type ReleaseAnimationsParams struct {
Animations []string `json:"animations"` // List of animation ids to seek.
}
// ReleaseAnimations releases a set of animations to no longer be
// manipulated.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-releaseAnimations
//
// parameters:
// animations - List of animation ids to seek.
func ReleaseAnimations(animations []string) *ReleaseAnimationsParams {
return &ReleaseAnimationsParams{
Animations: animations,
}
}
// Do executes Animation.releaseAnimations against the provided context.
func (p *ReleaseAnimationsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandReleaseAnimations, p, nil)
}
// ResolveAnimationParams gets the remote object of the Animation.
type ResolveAnimationParams struct {
AnimationID string `json:"animationId"` // Animation id.
}
// ResolveAnimation gets the remote object of the Animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-resolveAnimation
//
// parameters:
// animationID - Animation id.
func ResolveAnimation(animationID string) *ResolveAnimationParams {
return &ResolveAnimationParams{
AnimationID: animationID,
}
}
// ResolveAnimationReturns return values.
type ResolveAnimationReturns struct {
RemoteObject *runtime.RemoteObject `json:"remoteObject,omitempty"` // Corresponding remote object.
}
// Do executes Animation.resolveAnimation against the provided context.
//
// returns:
// remoteObject - Corresponding remote object.
func (p *ResolveAnimationParams) Do(ctx context.Context) (remoteObject *runtime.RemoteObject, err error) {
// execute
var res ResolveAnimationReturns
err = cdp.Execute(ctx, CommandResolveAnimation, p, &res)
if err != nil {
return nil, err
}
return res.RemoteObject, nil
}
// SeekAnimationsParams seek a set of animations to a particular time within
// each animation.
type SeekAnimationsParams struct {
Animations []string `json:"animations"` // List of animation ids to seek.
CurrentTime float64 `json:"currentTime"` // Set the current time of each animation.
}
// SeekAnimations seek a set of animations to a particular time within each
// animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-seekAnimations
//
// parameters:
// animations - List of animation ids to seek.
// currentTime - Set the current time of each animation.
func SeekAnimations(animations []string, currentTime float64) *SeekAnimationsParams {
return &SeekAnimationsParams{
Animations: animations,
CurrentTime: currentTime,
}
}
// Do executes Animation.seekAnimations against the provided context.
func (p *SeekAnimationsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSeekAnimations, p, nil)
}
// SetPausedParams sets the paused state of a set of animations.
type SetPausedParams struct {
Animations []string `json:"animations"` // Animations to set the pause state of.
Paused bool `json:"paused"` // Paused state to set to.
}
// SetPaused sets the paused state of a set of animations.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-setPaused
//
// parameters:
// animations - Animations to set the pause state of.
// paused - Paused state to set to.
func SetPaused(animations []string, paused bool) *SetPausedParams {
return &SetPausedParams{
Animations: animations,
Paused: paused,
}
}
// Do executes Animation.setPaused against the provided context.
func (p *SetPausedParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetPaused, p, nil)
}
// SetPlaybackRateParams sets the playback rate of the document timeline.
type SetPlaybackRateParams struct {
PlaybackRate float64 `json:"playbackRate"` // Playback rate for animations on page
}
// SetPlaybackRate sets the playback rate of the document timeline.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-setPlaybackRate
//
// parameters:
// playbackRate - Playback rate for animations on page
func SetPlaybackRate(playbackRate float64) *SetPlaybackRateParams {
return &SetPlaybackRateParams{
PlaybackRate: playbackRate,
}
}
// Do executes Animation.setPlaybackRate against the provided context.
func (p *SetPlaybackRateParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetPlaybackRate, p, nil)
}
// SetTimingParams sets the timing of an animation node.
type SetTimingParams struct {
AnimationID string `json:"animationId"` // Animation id.
Duration float64 `json:"duration"` // Duration of the animation.
Delay float64 `json:"delay"` // Delay of the animation.
}
// SetTiming sets the timing of an animation node.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-setTiming
//
// parameters:
// animationID - Animation id.
// duration - Duration of the animation.
// delay - Delay of the animation.
func SetTiming(animationID string, duration float64, delay float64) *SetTimingParams {
return &SetTimingParams{
AnimationID: animationID,
Duration: duration,
Delay: delay,
}
}
// Do executes Animation.setTiming against the provided context.
func (p *SetTimingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetTiming, p, nil)
}
// Command names.
const (
CommandDisable = "Animation.disable"
CommandEnable = "Animation.enable"
CommandGetCurrentTime = "Animation.getCurrentTime"
CommandGetPlaybackRate = "Animation.getPlaybackRate"
CommandReleaseAnimations = "Animation.releaseAnimations"
CommandResolveAnimation = "Animation.resolveAnimation"
CommandSeekAnimations = "Animation.seekAnimations"
CommandSetPaused = "Animation.setPaused"
CommandSetPlaybackRate = "Animation.setPlaybackRate"
CommandSetTiming = "Animation.setTiming"
)

1672
vendor/github.com/chromedp/cdproto/animation/easyjson.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

24
vendor/github.com/chromedp/cdproto/animation/events.go generated vendored Normal file
View File

@@ -0,0 +1,24 @@
package animation
// Code generated by cdproto-gen. DO NOT EDIT.
// EventAnimationCanceled event for when an animation has been cancelled.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#event-animationCanceled
type EventAnimationCanceled struct {
ID string `json:"id"` // Id of the animation that was cancelled.
}
// EventAnimationCreated event for each animation that has been created.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#event-animationCreated
type EventAnimationCreated struct {
ID string `json:"id"` // Id of the animation that was created.
}
// EventAnimationStarted event for animation that has been started.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#event-animationStarted
type EventAnimationStarted struct {
Animation *Animation `json:"animation"` // Animation that was started.
}

107
vendor/github.com/chromedp/cdproto/animation/types.go generated vendored Normal file
View File

@@ -0,0 +1,107 @@
package animation
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"errors"
"github.com/chromedp/cdproto/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// Animation animation instance.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-Animation
type Animation struct {
ID string `json:"id"` // Animation's id.
Name string `json:"name"` // Animation's name.
PausedState bool `json:"pausedState"` // Animation's internal paused state.
PlayState string `json:"playState"` // Animation's play state.
PlaybackRate float64 `json:"playbackRate"` // Animation's playback rate.
StartTime float64 `json:"startTime"` // Animation's start time.
CurrentTime float64 `json:"currentTime"` // Animation's current time.
Type Type `json:"type"` // Animation type of Animation.
Source *Effect `json:"source,omitempty"` // Animation's source animation node.
CSSID string `json:"cssId,omitempty"` // A unique ID for Animation representing the sources that triggered this CSS animation/transition.
}
// Effect animationEffect instance.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-AnimationEffect
type Effect struct {
Delay float64 `json:"delay"` // AnimationEffect's delay.
EndDelay float64 `json:"endDelay"` // AnimationEffect's end delay.
IterationStart float64 `json:"iterationStart"` // AnimationEffect's iteration start.
Iterations float64 `json:"iterations"` // AnimationEffect's iterations.
Duration float64 `json:"duration"` // AnimationEffect's iteration duration.
Direction string `json:"direction"` // AnimationEffect's playback direction.
Fill string `json:"fill"` // AnimationEffect's fill mode.
BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // AnimationEffect's target node.
KeyframesRule *KeyframesRule `json:"keyframesRule,omitempty"` // AnimationEffect's keyframes.
Easing string `json:"easing"` // AnimationEffect's timing function.
}
// KeyframesRule keyframes Rule.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-KeyframesRule
type KeyframesRule struct {
Name string `json:"name,omitempty"` // CSS keyframed animation's name.
Keyframes []*KeyframeStyle `json:"keyframes"` // List of animation keyframes.
}
// KeyframeStyle keyframe Style.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-KeyframeStyle
type KeyframeStyle struct {
Offset string `json:"offset"` // Keyframe's time offset.
Easing string `json:"easing"` // AnimationEffect's timing function.
}
// Type animation type of Animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-Animation
type Type string
// String returns the Type as string value.
func (t Type) String() string {
return string(t)
}
// Type values.
const (
TypeCSSTransition Type = "CSSTransition"
TypeCSSAnimation Type = "CSSAnimation"
TypeWebAnimation Type = "WebAnimation"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Type) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Type) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Type) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Type(in.String()) {
case TypeCSSTransition:
*t = TypeCSSTransition
case TypeCSSAnimation:
*t = TypeCSSAnimation
case TypeWebAnimation:
*t = TypeWebAnimation
default:
in.AddError(errors.New("unknown Type value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Type) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}