intercept
BaseFetchInterception
Base class to wait for a Fetch response matching a URL pattern. Use this to collect and decode a paused fetch response, while keeping the use block clean and returning its own result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tab
|
Connection
|
The Tab instance to monitor. |
required |
url_pattern
|
str
|
The URL pattern to match requests and responses. |
required |
request_stage
|
RequestStage
|
The stage of the fetch request to intercept (e.g., request or response). |
required |
resource_type
|
ResourceType
|
The type of resource to intercept (e.g., document, script, etc.). |
required |
Source code in zendriver/core/intercept.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
request: cdp.network.Request
async
property
Get the matched request.
Returns:
| Type | Description |
|---|---|
cdp.network.request
|
The matched request. |
request_stage = request_stage
instance-attribute
resource_type = resource_type
instance-attribute
response_body: tuple[str, bool]
async
property
Get the body of the matched response.
Returns:
| Type | Description |
|---|---|
str
|
The response body. |
response_future: asyncio.Future[cdp.fetch.RequestPaused] = asyncio.Future()
instance-attribute
tab = tab
instance-attribute
url_pattern = url_pattern
instance-attribute
__aenter__()
async
__aexit__(*args)
async
__init__(tab, url_pattern, request_stage, resource_type)
Source code in zendriver/core/intercept.py
continue_request(url=None, method=None, post_data=None, headers=None, intercept_response=None)
async
Source code in zendriver/core/intercept.py
continue_response(response_code=None, response_phrase=None, response_headers=None, binary_response_headers=None)
async
Source code in zendriver/core/intercept.py
fail_request(error_reason)
async
fulfill_request(response_code, response_headers=None, binary_response_headers=None, body=None, response_phrase=None)
async
Source code in zendriver/core/intercept.py
reset()
async
Resets the internal state, allowing the interception to be reused.