Skip to content

Commit

Permalink
Update docs for PLAYWRIGHT_ABORT_REQUEST
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta authored Jan 4, 2023
1 parent b3f154e commit 11a78a4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,20 @@ PLAYWRIGHT_MAX_PAGES_PER_CONTEXT = 4
Type `Optional[Union[Callable, str]]`, default `None`

A predicate function (or the path to a function) that receives a
`playwright.async_api.Request` object and must return `True` if the
request should be aborted, `False` otherwise. Coroutine functions
(`async def`) are supported.
[`playwright.async_api.Request`](https://playwright.dev/python/docs/api/class-request)
object and must return `True` if the request should be aborted, `False` otherwise.
Coroutine functions (`async def`) are supported.

Note that all requests will appear in the DEBUG level logs, however there will
be no corresponding response log lines for aborted requests. Aborted requests
are counted in the `playwright/request_count/aborted` job stats item.

```python
def should_abort_request(request):
return request.resource_type == "image"
return (
request.resource_type == "image"
or ".jpg" in request.url
)

PLAYWRIGHT_ABORT_REQUEST = should_abort_request
```
Expand Down

0 comments on commit 11a78a4

Please sign in to comment.