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,171 @@
// Package domstorage provides the Chrome DevTools Protocol
// commands, types, and events for the DOMStorage domain.
//
// Query and modify DOM storage.
//
// Generated by the cdproto-gen command.
package domstorage
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// ClearParams [no description].
type ClearParams struct {
StorageID *StorageID `json:"storageId"`
}
// Clear [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#method-clear
//
// parameters:
// storageID
func Clear(storageID *StorageID) *ClearParams {
return &ClearParams{
StorageID: storageID,
}
}
// Do executes DOMStorage.clear against the provided context.
func (p *ClearParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClear, p, nil)
}
// DisableParams disables storage tracking, prevents storage events from
// being sent to the client.
type DisableParams struct{}
// Disable disables storage tracking, prevents storage events from being sent
// to the client.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes DOMStorage.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// EnableParams enables storage tracking, storage events will now be
// delivered to the client.
type EnableParams struct{}
// Enable enables storage tracking, storage events will now be delivered to
// the client.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes DOMStorage.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// GetDOMStorageItemsParams [no description].
type GetDOMStorageItemsParams struct {
StorageID *StorageID `json:"storageId"`
}
// GetDOMStorageItems [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#method-getDOMStorageItems
//
// parameters:
// storageID
func GetDOMStorageItems(storageID *StorageID) *GetDOMStorageItemsParams {
return &GetDOMStorageItemsParams{
StorageID: storageID,
}
}
// GetDOMStorageItemsReturns return values.
type GetDOMStorageItemsReturns struct {
Entries []Item `json:"entries,omitempty"`
}
// Do executes DOMStorage.getDOMStorageItems against the provided context.
//
// returns:
// entries
func (p *GetDOMStorageItemsParams) Do(ctx context.Context) (entries []Item, err error) {
// execute
var res GetDOMStorageItemsReturns
err = cdp.Execute(ctx, CommandGetDOMStorageItems, p, &res)
if err != nil {
return nil, err
}
return res.Entries, nil
}
// RemoveDOMStorageItemParams [no description].
type RemoveDOMStorageItemParams struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
}
// RemoveDOMStorageItem [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#method-removeDOMStorageItem
//
// parameters:
// storageID
// key
func RemoveDOMStorageItem(storageID *StorageID, key string) *RemoveDOMStorageItemParams {
return &RemoveDOMStorageItemParams{
StorageID: storageID,
Key: key,
}
}
// Do executes DOMStorage.removeDOMStorageItem against the provided context.
func (p *RemoveDOMStorageItemParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRemoveDOMStorageItem, p, nil)
}
// SetDOMStorageItemParams [no description].
type SetDOMStorageItemParams struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
Value string `json:"value"`
}
// SetDOMStorageItem [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#method-setDOMStorageItem
//
// parameters:
// storageID
// key
// value
func SetDOMStorageItem(storageID *StorageID, key string, value string) *SetDOMStorageItemParams {
return &SetDOMStorageItemParams{
StorageID: storageID,
Key: key,
Value: value,
}
}
// Do executes DOMStorage.setDOMStorageItem against the provided context.
func (p *SetDOMStorageItemParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDOMStorageItem, p, nil)
}
// Command names.
const (
CommandClear = "DOMStorage.clear"
CommandDisable = "DOMStorage.disable"
CommandEnable = "DOMStorage.enable"
CommandGetDOMStorageItems = "DOMStorage.getDOMStorageItems"
CommandRemoveDOMStorageItem = "DOMStorage.removeDOMStorageItem"
CommandSetDOMStorageItem = "DOMStorage.setDOMStorageItem"
)

1026
vendor/github.com/chromedp/cdproto/domstorage/easyjson.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
package domstorage
// Code generated by cdproto-gen. DO NOT EDIT.
// EventDomStorageItemAdded [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#event-domStorageItemAdded
type EventDomStorageItemAdded struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
NewValue string `json:"newValue"`
}
// EventDomStorageItemRemoved [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#event-domStorageItemRemoved
type EventDomStorageItemRemoved struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
}
// EventDomStorageItemUpdated [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#event-domStorageItemUpdated
type EventDomStorageItemUpdated struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
OldValue string `json:"oldValue"`
NewValue string `json:"newValue"`
}
// EventDomStorageItemsCleared [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#event-domStorageItemsCleared
type EventDomStorageItemsCleared struct {
StorageID *StorageID `json:"storageId"`
}

16
vendor/github.com/chromedp/cdproto/domstorage/types.go generated vendored Normal file
View File

@@ -0,0 +1,16 @@
package domstorage
// Code generated by cdproto-gen. DO NOT EDIT.
// StorageID DOM Storage identifier.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#type-StorageId
type StorageID struct {
SecurityOrigin string `json:"securityOrigin"` // Security origin for the storage.
IsLocalStorage bool `json:"isLocalStorage"` // Whether the storage is local storage (not session storage).
}
// Item DOM Storage item.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOMStorage#type-Item
type Item []string