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,321 @@
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
package inspector
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector(in *jlexer.Lexer, out *EventTargetReloadedAfterCrash) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector(out *jwriter.Writer, in EventTargetReloadedAfterCrash) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventTargetReloadedAfterCrash) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventTargetReloadedAfterCrash) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventTargetReloadedAfterCrash) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventTargetReloadedAfterCrash) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector1(in *jlexer.Lexer, out *EventTargetCrashed) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector1(out *jwriter.Writer, in EventTargetCrashed) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventTargetCrashed) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventTargetCrashed) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventTargetCrashed) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventTargetCrashed) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector1(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector2(in *jlexer.Lexer, out *EventDetached) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "reason":
(out.Reason).UnmarshalEasyJSON(in)
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector2(out *jwriter.Writer, in EventDetached) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"reason\":"
out.RawString(prefix[1:])
(in.Reason).MarshalEasyJSON(out)
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventDetached) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventDetached) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventDetached) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventDetached) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector2(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector3(in *jlexer.Lexer, out *EnableParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector3(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector3(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector4(in *jlexer.Lexer, out *DisableParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector4(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoInspector4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoInspector4(l, v)
}

22
vendor/github.com/chromedp/cdproto/inspector/events.go generated vendored Normal file
View File

@@ -0,0 +1,22 @@
package inspector
// Code generated by cdproto-gen. DO NOT EDIT.
// EventDetached fired when remote debugging connection is about to be
// terminated. Contains detach reason.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Inspector#event-detached
type EventDetached struct {
Reason DetachReason `json:"reason"` // The reason why connection has been terminated.
}
// EventTargetCrashed fired when debugging target has crashed.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Inspector#event-targetCrashed
type EventTargetCrashed struct{}
// EventTargetReloadedAfterCrash fired when debugging target has reloaded
// after crash.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Inspector#event-targetReloadedAfterCrash
type EventTargetReloadedAfterCrash struct{}

View File

@@ -0,0 +1,49 @@
// Package inspector provides the Chrome DevTools Protocol
// commands, types, and events for the Inspector domain.
//
// Generated by the cdproto-gen command.
package inspector
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// DisableParams disables inspector domain notifications.
type DisableParams struct{}
// Disable disables inspector domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Inspector#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Inspector.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// EnableParams enables inspector domain notifications.
type EnableParams struct{}
// Enable enables inspector domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Inspector#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Inspector.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// Command names.
const (
CommandDisable = "Inspector.disable"
CommandEnable = "Inspector.enable"
)

61
vendor/github.com/chromedp/cdproto/inspector/types.go generated vendored Normal file
View File

@@ -0,0 +1,61 @@
package inspector
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"errors"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// DetachReason detach reason.
//
// See: ( -- none -- )
type DetachReason string
// String returns the DetachReason as string value.
func (t DetachReason) String() string {
return string(t)
}
// DetachReason values.
const (
DetachReasonTargetClosed DetachReason = "target_closed"
DetachReasonCanceledByUser DetachReason = "canceled_by_user"
DetachReasonReplacedWithDevtools DetachReason = "replaced_with_devtools"
DetachReasonRenderProcessGone DetachReason = "Render process gone."
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t DetachReason) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t DetachReason) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *DetachReason) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch DetachReason(in.String()) {
case DetachReasonTargetClosed:
*t = DetachReasonTargetClosed
case DetachReasonCanceledByUser:
*t = DetachReasonCanceledByUser
case DetachReasonReplacedWithDevtools:
*t = DetachReasonReplacedWithDevtools
case DetachReasonRenderProcessGone:
*t = DetachReasonRenderProcessGone
default:
in.AddError(errors.New("unknown DetachReason value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *DetachReason) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}