Skip to content

获取协议

Chrome DevTools 协议的获取域命令、事件和类型。

方法

pydoll.protocol.fetch.methods

RequestId module-attribute

RequestId = str

GetResponseBodyResponse module-attribute

GetResponseBodyResponse = Response[GetResponseBodyResult]

TakeResponseBodyAsStreamResponse module-attribute

TakeResponseBodyAsStreamResponse = Response[TakeResponseBodyAsStreamResult]

ContinueRequestCommand module-attribute

ContinueRequestCommand = Command[ContinueRequestParams, EmptyResponse]

ContinueResponseCommand module-attribute

ContinueResponseCommand = Command[ContinueResponseParams, EmptyResponse]

ContinueWithAuthCommand module-attribute

ContinueWithAuthCommand = Command[ContinueWithAuthParams, EmptyResponse]

DisableCommand module-attribute

DisableCommand = Command[EmptyParams, EmptyResponse]

EnableCommand module-attribute

FailRequestCommand module-attribute

FailRequestCommand = Command[FailRequestParams, EmptyResponse]

FulfillRequestCommand module-attribute

FulfillRequestCommand = Command[FulfillRequestParams, EmptyResponse]

GetResponseBodyCommand module-attribute

TakeResponseBodyAsStreamCommand module-attribute

FetchMethod

Bases: str, Enum

Fetch domain method names.

CONTINUE_REQUEST class-attribute instance-attribute

CONTINUE_REQUEST = 'Fetch.continueRequest'

CONTINUE_RESPONSE class-attribute instance-attribute

CONTINUE_RESPONSE = 'Fetch.continueResponse'

CONTINUE_WITH_AUTH class-attribute instance-attribute

CONTINUE_WITH_AUTH = 'Fetch.continueWithAuth'

DISABLE class-attribute instance-attribute

DISABLE = 'Fetch.disable'

ENABLE class-attribute instance-attribute

ENABLE = 'Fetch.enable'

FAIL_REQUEST class-attribute instance-attribute

FAIL_REQUEST = 'Fetch.failRequest'

FULFILL_REQUEST class-attribute instance-attribute

FULFILL_REQUEST = 'Fetch.fulfillRequest'

GET_RESPONSE_BODY class-attribute instance-attribute

GET_RESPONSE_BODY = 'Fetch.getResponseBody'

TAKE_RESPONSE_BODY_AS_STREAM class-attribute instance-attribute

TAKE_RESPONSE_BODY_AS_STREAM = 'Fetch.takeResponseBodyAsStream'

EnableParams

Bases: TypedDict

Parameters for enabling the fetch domain.

patterns instance-attribute

patterns

handleAuthRequests instance-attribute

handleAuthRequests

FailRequestParams

Bases: TypedDict

Parameters for failing a request.

requestId instance-attribute

requestId

errorReason instance-attribute

errorReason

FulfillRequestParams

Bases: TypedDict

Parameters for fulfilling a request.

requestId instance-attribute

requestId

responseCode instance-attribute

responseCode

responseHeaders instance-attribute

responseHeaders

binaryResponseHeaders instance-attribute

binaryResponseHeaders

body instance-attribute

body

responsePhrase instance-attribute

responsePhrase

ContinueRequestParams

Bases: TypedDict

Parameters for continuing a request.

requestId instance-attribute

requestId

url instance-attribute

url

method instance-attribute

method

postData instance-attribute

postData

headers instance-attribute

headers

interceptResponse instance-attribute

interceptResponse

ContinueWithAuthParams

Bases: TypedDict

Parameters for continuing a request with authentication.

requestId instance-attribute

requestId

authChallengeResponse instance-attribute

authChallengeResponse

ContinueResponseParams

Bases: TypedDict

Parameters for continuing a response.

requestId instance-attribute

requestId

responseCode instance-attribute

responseCode

responsePhrase instance-attribute

responsePhrase

responseHeaders instance-attribute

responseHeaders

binaryResponseHeaders instance-attribute

binaryResponseHeaders

GetResponseBodyParams

Bases: TypedDict

Parameters for getting response body.

requestId instance-attribute

requestId

TakeResponseBodyAsStreamParams

Bases: TypedDict

Parameters for taking response body as stream.

requestId instance-attribute

requestId

GetResponseBodyResult

Bases: TypedDict

Result for getResponseBody command.

body instance-attribute

body

base64Encoded instance-attribute

base64Encoded

TakeResponseBodyAsStreamResult

Bases: TypedDict

Result for takeResponseBodyAsStream command.

stream instance-attribute

stream

事件

pydoll.protocol.fetch.events

RequestPausedEvent module-attribute

RequestPausedEvent = CDPEvent[RequestPausedEventParams]

AuthRequiredEvent module-attribute

AuthRequiredEvent = CDPEvent[AuthRequiredEventParams]

FetchEvent

Bases: str, Enum

Events from the Fetch domain of the Chrome DevTools Protocol.

This enumeration contains the names of Fetch-related events that can be received from the Chrome DevTools Protocol. These events provide information about network requests that can be intercepted, modified, or responded to by the client.

AUTH_REQUIRED class-attribute instance-attribute

AUTH_REQUIRED = 'Fetch.authRequired'

Issued when the domain is enabled with handleAuthRequests set to true. The request is paused until client responds with continueWithAuth.

PARAMETER DESCRIPTION
requestId

Each request the page makes will have a unique id.

TYPE: RequestId

request

The details of the request.

TYPE: Request

frameId

The id of the frame that initiated the request.

TYPE: FrameId

resourceType

How the requested resource will be used.

TYPE: ResourceType

authChallenge

Details of the Authorization Challenge encountered. If this is set, client should respond with continueRequest that contains AuthChallengeResponse.

TYPE: AuthChallenge

REQUEST_PAUSED class-attribute instance-attribute

REQUEST_PAUSED = 'Fetch.requestPaused'

Issued when the domain is enabled and the request URL matches the specified filter.

The request is paused until the client responds with one of continueRequest, failRequest or fulfillRequest. The stage of the request can be determined by presence of responseErrorReason and responseStatusCode -- the request is at the response stage if either of these fields is present and in the request stage otherwise.

Redirect responses and subsequent requests are reported similarly to regular responses and requests. Redirect responses may be distinguished by the value of responseStatusCode (which is one of 301, 302, 303, 307, 308) along with presence of the location header. Requests resulting from a redirect will have redirectedRequestId field set.

PARAMETER DESCRIPTION
requestId

Each request the page makes will have a unique id.

TYPE: RequestId

request

The details of the request.

TYPE: Request

frameId

The id of the frame that initiated the request.

TYPE: FrameId

resourceType

How the requested resource will be used.

TYPE: ResourceType

responseErrorReason

Response error if intercepted at response stage.

TYPE: ErrorReason

responseStatusCode

Response code if intercepted at response stage.

TYPE: int

responseStatusText

Response status text if intercepted at response stage.

TYPE: str

responseHeaders

Response headers if intercepted at the response stage.

TYPE: array[HeaderEntry]

networkId

If the intercepted request had a corresponding Network.requestWillBeSent event fired for it, then this networkId will be the same as the requestId present in the requestWillBeSent event.

TYPE: RequestId

redirectedRequestId

If the request is due to a redirect response from the server, the id of the request that has caused the redirect.

TYPE: RequestId

AuthRequiredEventParams

Bases: TypedDict

Parameters for the AuthRequired event.

requestId instance-attribute

requestId

request instance-attribute

request

frameId instance-attribute

frameId

resourceType instance-attribute

resourceType

authChallenge instance-attribute

authChallenge

RequestPausedEventParams

Bases: TypedDict

Parameters for the RequestPaused event.

requestId instance-attribute

requestId

request instance-attribute

request

frameId instance-attribute

frameId

resourceType instance-attribute

resourceType

responseErrorReason instance-attribute

responseErrorReason

responseStatusCode instance-attribute

responseStatusCode

responseStatusText instance-attribute

responseStatusText

类型

pydoll.protocol.fetch.types

RequestStage

Bases: str, Enum

Stages of the request to handle.

REQUEST class-attribute instance-attribute

REQUEST = 'Request'

RESPONSE class-attribute instance-attribute

RESPONSE = 'Response'

AuthChallengeSource

Bases: str, Enum

Source of the authentication challenge.

SERVER class-attribute instance-attribute

SERVER = 'Server'

PROXY class-attribute instance-attribute

PROXY = 'Proxy'

AuthChallengeResponseType

Bases: str, Enum

The decision on what to do in response to the authorization challenge.

DEFAULT class-attribute instance-attribute

DEFAULT = 'Default'

CANCEL_AUTH class-attribute instance-attribute

CANCEL_AUTH = 'CancelAuth'

PROVIDE_CREDENTIALS class-attribute instance-attribute

PROVIDE_CREDENTIALS = 'ProvideCredentials'

RequestPattern

Bases: TypedDict

Pattern for request interception.

urlPattern instance-attribute

urlPattern

resourceType instance-attribute

resourceType

requestStage instance-attribute

requestStage

HeaderEntry

Bases: TypedDict

Response HTTP header entry.

name instance-attribute

name

value instance-attribute

value

AuthChallenge

Bases: TypedDict

Authorization challenge for HTTP status code 401 or 407.

source instance-attribute

source

origin instance-attribute

origin

scheme instance-attribute

scheme

realm instance-attribute

realm

AuthChallengeResponse

Bases: TypedDict

Response to an AuthChallenge.

response instance-attribute

response

username instance-attribute

username

password instance-attribute

password