selenium-wire-lw


Nameselenium-wire-lw JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryExtends Selenium to give you the ability to inspect requests made by the browser, with built-in support for undetected-geckodriver-lw and undetected-chromedriver
upload_time2025-07-09 23:22:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords selenium archival archiving selenium-wire
VCS
bugtrack_url
requirements mitmproxy selenium brotli zstd pytest httpbin
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Selenium Wire

This is a fork of 7x11x13's [selenium-wire-2](https://github.com/7x11x13/selenium-wire-2), which itself is a fork of Will Keeling's [selenium-wire](https://github.com/wkeeling/selenium-wire). This fork notably features both `undetected-geckodriver-lw` and `undetected-chromedriver` integration.

This fork exists because selenium-wire has been officially abandoned, selenium-wire-2 does not appear to be maintained, and I need selenium-wire for an archival project of mine, so here we go.

Selenium Wire extends [Selenium\'s](https://www.selenium.dev/documentation/en/) Python bindings to give you access to the underlying requests made by the browser. You author your code in the same way as you do with Selenium, but you get extra APIs for inspecting requests and responses and making changes to them on the fly.

## Simple Example

``` python
from seleniumwire import webdriver  # Import from seleniumwire

# Create a new instance of the Chrome driver
driver = webdriver.Chrome()

# Go to the Google home page
driver.get("https://www.google.com")

# Access requests via the `requests` attribute
for request in driver.requests:
    if request.response:
        print(
            request.url,
            request.response.status_code,
            request.response.headers["Content-Type"]
        )
```

Prints:

```bash
https://www.google.com/ 200 text/html; charset=UTF-8
https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png 200 image/png
https://consent.google.com/status?continue=https://www.google.com&pc=s&timestamp=1531511954&gl=GB 204 text/html; charset=utf-8
https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png 200 image/png
https://ssl.gstatic.com/gb/images/i2_2ec824b0.png 200 image/png
https://www.google.com/gen_204?s=webaft&t=aft&atyp=csi&ei=kgRJW7DBONKTlwTK77wQ&rt=wsrt.366,aft.58,prt.58 204 text/html; charset=UTF-8
...
```

## Features

-   Pure Python, user-friendly API
-   HTTP and HTTPS requests captured
-   Intercept requests and responses
-   Modify headers, parameters, body content on the fly
-   Capture websocket messages
-   HAR format supported
-   Proxy server support

## Compatibilty

- Python 3.10+[^1]
- Selenium 4.10.0+
- Chrome, Firefox, Edge, Safari, and Remote Webdriver supported
- `UndetectedFirefox` if `undetected-geckodriver-lw` is installed
- `UndetectedChrome` if `undetected-chromedriver` is installed

## Installation

Install using pip:

``` bash
pip install selenium-wire-lw
```

If you get an error about not being able to build cryptography you may
be running an old version of pip. Try upgrading pip with
`python -m pip install --upgrade pip` and then re-run the above command.

In addition to the mainline install, three different variants are also supported:

* `selenium-wire-lw[uf]`: `undetected-geckodriver-lw` is also installed
* `selenium-wire-lw[uc]`: `undetected-chromedriver` is also installed
* `selenium-wire-lw[ud]`: same as both `uf` and `uc`

### Browser Setup

No specific configuration should be necessary except to ensure that you have downloaded the relevent webdriver executable for your browser and placed it somewhere on your system PATH.

-   [Download](https://sites.google.com/chromium.org/driver/) webdriver for Chrome
-   [Download](https://github.com/mozilla/geckodriver/) webdriver for Firefox
-   [Download](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) webdriver for Edge

> [!warning]
>
> If you're using `snap`, first, my sincerest condolences.
>
> You may need to `export SE_GECKODRIVER=/snap/bin/geckodriver` for Geckodriver to be correctly loaded. Chromedriver may have a similar problem with a similar solution, but I have never tried.

### OpenSSL

Selenium Wire requires OpenSSL for decrypting HTTPS requests. This is
probably already installed on your system (you can check by running
`openssl version` on the command line). If it\'s not installed you can
install it with:

**Linux**

``` bash
# For apt based Linux systems
sudo apt install openssl

# For RPM based Linux systems
sudo yum install openssl

# For Linux alpine
sudo apk add openssl
```

**MacOS**

``` bash
brew install openssl
```

**Windows**

No installation is required.

### Certificates

See
<https://docs.mitmproxy.org/stable/concepts-certificates/#the-mitmproxy-certificate-authority>

The CA certificate is stored in the directory specified by
`storage_base_dir`.

## Creating the Webdriver

Ensure that you import `webdriver` from the `seleniumwire` package:

``` python
from seleniumwire import webdriver
```

Then just instantiate the webdriver as you would if you were using
Selenium directly. You can pass in any desired capabilities or browser
specific options - such as the executable path, headless mode etc.
Selenium Wire also has it\'s [own options](#all-options) that can be
passed in the `seleniumwire_options` attribute.

``` python
# Create the driver with no options (use defaults)
driver = webdriver.Chrome()

# Or create using browser specific options and/or seleniumwire_options options
driver = webdriver.Chrome(
    options = webdriver.ChromeOptions(...),
    seleniumwire_options={...}
)
```

Note that for sub-packages of `webdriver`, you should continue to import
these directly from `selenium`. For example, to import `WebDriverWait`:

``` python
# Sub-packages of webdriver must still be imported from `selenium` itself
from selenium.webdriver.support.ui import WebDriverWait
```

**Remote Webdriver**

Selenium Wire has limited support for using the remote webdriver client.
When you create an instance of the remote webdriver, you need to specify
the hostname or IP address of the machine (or container) running
Selenium Wire. This allows the remote instance to communicate back to
Selenium Wire with its requests and responses.

``` python
options = SeleniumWireOptions(
    host=hostname_or_ip  # Address of the machine running Selenium Wire. Explicitly use 127.0.0.1 rather than localhost if remote session is running locally.
)
driver = webdriver.Remote(
    command_executor="http://www.example.com",
    seleniumwire_options=options
)
```

If the machine running the browser needs to use a different address to
talk to the machine running Selenium Wire you need to configure the
browser manually. [This
issue](https://github.com/wkeeling/selenium-wire/issues/220) goes into
more detail.

## Accessing Requests

Selenium Wire captures all HTTP/HTTPS traffic made by the browser[^1].
The following attributes provide access to requests and responses.

`driver.requests`

:   The list of captured requests in chronological order.

`driver.last_request`

:   Convenience attribute for retrieving the most recently captured
    request. This is more efficient than using `driver.requests[-1]`.

`driver.wait_for_request(pat, timeout=10)`

:   This method will wait until it sees a request matching a pattern.
    The `pat` attribute will be matched within the request URL. `pat`
    can be a simple substring or a regular expression. Note that
    `driver.wait_for_request()` doesn\'t *make* a request, it just
    *waits* for a previous request made by some other action and it will
    return the first request it finds. Also note that since `pat` can be
    a regular expression, you must escape special characters such as
    question marks with a slash. A `TimeoutException` is raised if no
    match is found within the timeout period.

    For example, to wait for an AJAX request to return after a button is
    clicked:

    ``` python
    # Click a button that triggers a background request to https://server/api/products/12345/
    button_element.click()

    # Wait for the request/response to complete
    request = driver.wait_for_request("/api/products/12345/")
    ```

`driver.har`

:   A JSON formatted HAR archive of HTTP transactions that have taken
    place. HAR capture is turned off by default and you must set the
    `enable_har` [option](#all-options) to `True` before using
    `driver.har`.

`driver.iter_requests()`

:   Returns an iterator over captured requests. Useful when dealing with
    a large number of requests.

`driver.request_interceptor`

:   Used to set a request interceptor. See [Intercepting Requests and
    Responses](#intercepting-requests-and-responses).

`driver.response_interceptor`

:   Used to set a response interceptor.

**Clearing Requests**

To clear previously captured requests and HAR entries, use `del`:

``` python
del driver.requests
```

## Request Objects

Request objects have the following attributes.

`body`

:   The request body as `bytes`. If the request has no body the value of
    `body` will be empty, i.e. `b""`.

`certificate_list`

:   Information about the server SSL certificates. Empty for non-HTTPS
    requests.

`date`

:   The datetime the request was made.

`headers`

:   A dictionary-like object of request headers. Headers are
    case-insensitive and duplicates are permitted. Asking for
    `request.headers["user-agent"]` will return the value of the
    `User-Agent` header. If you wish to replace a header, make sure you
    delete the existing header first with
    `del request.headers["header-name"]`, otherwise you\'ll create a
    duplicate.

`host`

:   The request host, e.g. `www.example.com`

`method`

:   The HTTP method, e.g. `GET` or `POST` etc.

`params`

:   A dictionary of request parameters. If a parameter with the same
    name appears more than once in the request, it\'s value in the
    dictionary will be a list.

`path`

:   The request path, e.g. `/some/path/index.html`

`querystring`

:   The query string, e.g. `foo=bar&spam=eggs`

`response`

:   The [response object](#response-objects) associated with the
    request. This will be `None` if the request has no response.

`url`

:   The request URL, e.g.
    `https://www.example.com/some/path/index.html?foo=bar&spam=eggs`

`ws_messages`

:   Where the request is a websocket handshake request (normally with a
    URL starting `wss://`) then `ws_messages` will contain a list of any
    websocket messages sent and received. See [WebSocketMessage
    Objects](#websocketmessage-objects).

Request objects have the following methods.

`abort(error_code=403)`

:   Trigger immediate termination of the request with the supplied error
    code. For use within request interceptors. See [Example: Block a
    request](#example-block-a-request).

`create_response(status_code, headers=(), body=b"")`

:   Create a response and return it without sending any data to the
    remote server. For use within request interceptors. See [Example:
    Mock a response](#example-mock-a-response).

`decompress_body()` 
:   Returns the body decompressed with the method indicated by `Content-Encoding`. If this header is missing, it's assumed the body isn't compressed, and it's returned as-is

### WebSocketMessage Objects

These objects represent websocket messages sent between the browser and
server and vice versa. They are held in a list by `request.ws_messages`
on websocket handshake requests. They have the following attributes.

`content`

:   The message content which may be either `str` or `bytes`.

`date`

:   The datetime of the message.

`from_client`

:   `True` when the message was sent by the client and `False` when sent
    by the server.

## Response Objects

Response objects have the following attributes.

`body`

:   The response body as `bytes`. If the response has no body the value
    of `body` will be empty, i.e. `b""`. Sometimes the body may have
    been compressed by the server. You can prevent this with the
    `disable_encoding` [option](#all-options). To manually decode an
    encoded response body you can do:

``` python
from seleniumwire.utils import decode

body = decode(response.body, response.headers.get("Content-Encoding", "identity"))
```

`date`

:   The datetime the response was received.

`headers`

:   A dictionary-like object of response headers. Headers are
    case-insensitive and duplicates are permitted. Asking for
    `response.headers["content-length"]` will return the value of the
    `Content-Length` header. If you wish to replace a header, make sure
    you delete the existing header first with
    `del response.headers["header-name"]`, otherwise you\'ll create a
    duplicate.

`reason`

:   The reason phrase, e.g. `OK` or `Not Found` etc.

`status_code`

:   The status code of the response, e.g. `200` or `404` etc.

Response objects have the following methods:

`decompress_body()` 
:   Returns the body decompressed with the method indicated by `Content-Encoding`. If this header is missing, it's assumed the body isn't compressed, and it's returned as-is

## Intercepting Requests and Responses

As well as capturing requests and responses, Selenium Wire allows you to
modify them on the fly using interceptors. An interceptor is a function
that gets invoked with requests and responses as they pass through
Selenium Wire. Within an interceptor you can modify the request and
response as you see fit.

You set your interceptor functions using the
`driver.request_interceptor` and `driver.response_interceptor`
attributes before you start using the driver. A request interceptor
should accept a single argument for the request. A response interceptor
should accept two arguments, one for the originating request and one for
the response.

### Example: Add a request header

``` python
def interceptor(request):
    request.headers["New-Header"] = "Some Value"

driver.request_interceptor = interceptor
driver.get(...)

# All requests will now contain New-Header
```

How can I check that a header has been set correctly? You can print the
headers from captured requests after the page has loaded using
`driver.requests`, or alternatively point the webdriver at
<https://httpbin.org/headers> which will echo the request headers back
to the browser so you can view them.

### Example: Replace an existing request header

Duplicate header names are permitted in an HTTP request, so before
setting the replacement header you must first delete the existing header
using `del` like in the following example, otherwise two headers with
the same name will exist (`request.headers` is a special dictionary-like
object that allows duplicates).

``` python
def interceptor(request):
    del request.headers["Referer"]  # Remember to delete the header first
    request.headers["Referer"] = "some_referer"  # Spoof the referer

driver.request_interceptor = interceptor
driver.get(...)

# All requests will now use "some_referer" for the referer
```

### Example: Add a response header

``` python
def interceptor(request, response):  # A response interceptor takes two args
    if request.url == "https://server.com/some/path":
        response.headers["New-Header"] = "Some Value"

driver.response_interceptor = interceptor
driver.get(...)

# Responses from https://server.com/some/path will now contain New-Header
```

### Example: Add a request parameter

Request parameters work differently to headers in that they are
calculated when they are set on the request. That means that you first
have to read them, then update them, and then write them back - like in
the following example. Parameters are held in a regular dictionary, so
parameters with the same name will be overwritten.

``` python
def interceptor(request):
    params = request.params
    params["foo"] = "bar"
    request.params = params

driver.request_interceptor = interceptor
driver.get(...)

# foo=bar will be added to all requests
```

### Example: Update JSON in a POST request body

``` python
import json

def interceptor(request):
    if request.method == "POST" and request.headers["Content-Type"] == "application/json":
        # The body is in bytes so convert to a string
        body = request.body.decode("utf-8")
        # Load the JSON
        data = json.loads(body)
        # Add a new property
        data["foo"] = "bar"
        # Set the JSON back on the request
        request.body = json.dumps(data).encode("utf-8")
        # Update the content length
        del request.headers["Content-Length"]
        request.headers["Content-Length"] = str(len(request.body))

driver.request_interceptor = interceptor
driver.get(...)
```

### Example: Basic authentication

If a site requires a username/password, you can use a request
interceptor to add authentication credentials to each request. This will
stop the browser from displaying a username/password pop-up.

``` python
import base64

auth = (
    base64.encodebytes("my_username:my_password".encode())
    .decode()
    .strip()
)

def interceptor(request):
    if request.host == "host_that_needs_auth":
        request.headers["Authorization"] = f"Basic {auth}"

driver.request_interceptor = interceptor
driver.get(...)

# Credentials will be transmitted with every request to "host_that_needs_auth"
```

### Example: Block a request

You can use `request.abort()` to block a request and send an immediate
response back to the browser. An optional error code can be supplied.
The default is 403 (forbidden).

``` python
def interceptor(request):
    # Block PNG, JPEG and GIF images
    if request.path.endswith((".png", ".jpg", ".gif")):
        request.abort()

driver.request_interceptor = interceptor
driver.get(...)

# Requests for PNG, JPEG and GIF images will result in a 403 Forbidden
```

### Example: Mock a response

You can use `request.create_response()` to send a custom reply back to
the browser. No data will be sent to the remote server.

``` python
def interceptor(request):
    if request.url == "https://server.com/some/path":
        request.create_response(
            status_code=200,
            headers={"Content-Type": "text/html"},  # Optional headers dictionary
            body="<html>Hello World!</html>"  # Optional body
        )

driver.request_interceptor = interceptor
driver.get(...)

# Requests to https://server.com/some/path will have their responses mocked
```

*Have any other examples you think could be useful? Feel free to submit
a PR.*

### Unset an interceptor

To unset an interceptor, use `del`:

``` python
del driver.request_interceptor
del driver.response_interceptor
```

## Limiting Request Capture

Selenium Wire works by redirecting browser traffic through an internal
proxy server it spins up in the background. As requests flow through the
proxy they are intercepted and captured. Capturing requests can slow
things down a little but there are a few things you can do to restrict
what gets captured.

`driver.include_urls` and `driver.exclude_urls`

:   TODO This accepts a list of regular expressions that will match the
    URLs to be captured. It should be set on the driver before making
    any requests. When empty (the default) all URLs are captured.

    ``` python
    driver.include_urls = [
        ".*stackoverflow.*",
        ".*github.*"
    ]

    driver.get(...)  # Start making requests

    # Only request URLs containing "stackoverflow" or "github" will now be captured
    ```

    ``` python
    driver.exclude_urls = [
        ".*stackoverflow.*",
        ".*github.*"
    ]

    driver.get(...)  # Start making requests

    # Only request URLs not containing "stackoverflow" or "github" will now be captured
    ```

    Note that even if a request is out of scope and not captured, it
    will still travel through Selenium Wire.

`seleniumwire_options.disable_capture`

:   Use this option to switch off request capture. Requests will still
    pass through Selenium Wire and through any upstream proxy you have
    configured but they won\'t be intercepted or stored. Request
    interceptors will not execute.

`seleniumwire_options.exclude_hosts`

:   Use this option to bypass Selenium Wire entirely. Any requests made
    to addresses listed here will go direct from the browser to the
    server without involving Selenium Wire. Note that if you\'ve
    configured an upstream proxy then these requests will also bypass
    that proxy.

`request.abort()`

:   You can abort a request early by using `request.abort()` from within
    a [request interceptor](#intercepting-requests-and-responses). This
    will send an immediate response back to the client without the
    request travelling any further. You can use this mechanism to block
    certain types of requests (e.g. images) to improve page load
    performance.

    ``` python
    def interceptor(request):
        # Block PNG, JPEG and GIF images
        if request.path.endswith((".png", ".jpg", ".gif")):
            request.abort()

    driver.request_interceptor = interceptor

    driver.get(...)  # Start making requests
    ```

## Request Storage

Captured requests and responses are stored in the home folder by default
(that\'s `~/` on Linux/Mac and usually `C:\Users\<username>` on Windows)
in a sub-folder called `.seleniumwire`. To change where the
`.seleniumwire` folder gets created you can use the `storage_base_dir`
option:

``` python
options = SeleniumWireOptions(
    storage_base_dir="/my/storage/folder"  # .seleniumwire will get created here
)
driver = webdriver.Chrome(seleniumwire_options=options)
```

### In-Memory Storage

Selenium Wire also supports storing requests and responses in memory
only, which may be useful in certain situations - e.g. if you\'re
running short lived Docker containers and don\'t want the overhead of
disk persistence. You can enable in-memory storage by setting the
`request_storage` option to `memory`:

``` python
from seleniumwire import SeleniumWireOptions
options = SeleniumWireOptions(request_storage="memory")
driver = webdriver.Chrome(seleniumwire_options=options)
```

If you\'re concerned about the amount of memory that may be consumed,
you can restrict the number of requests that are stored with the
`request_storage_max_size` option:

``` python
from seleniumwire import SeleniumWireOptions
options = SeleniumWireOptions(
    request_storage="memory",
    request_storage_max_size=100  # Store no more than 100 requests in memory
)
driver = webdriver.Chrome(seleniumwire_options=options)
```

When the max size is reached, older requests are discarded as newer
requests arrive. Keep in mind that if you restrict the number of
requests being stored, requests may have disappeared from storage by the
time you come to retrieve them with `driver.requests` or
`driver.wait_for_request()` etc.

## Upstream Proxies

If the site you are accessing sits behind a proxy server you can tell
Selenium Wire about that proxy server in the options you pass to the
webdriver.

The configuration takes the following format:

``` python
from seleniumwire import ProxyConfig, SeleniumWireOptions
options = SeleniumWireOptions(
    upstream_proxy=ProxyConfig(
        http="http://192.168.10.100:8888",
        https="https://192.168.10.100:8888"
    )
)
driver = webdriver.Chrome(seleniumwire_options=options)
```

To use HTTP Basic Auth with your proxy, specify the username and
password in the URL:

``` python
from seleniumwire import ProxyConfig, SeleniumWireOptions
options = SeleniumWireOptions(
    upstream_proxy=ProxyConfig(
        https="https://user:pass@192.168.10.100:8888"
    }
}
```

If no upstream proxy config is supplied, seleniumwire uses the
`HTTP_PROXY` and `HTTPS_PROXY` environment variables:

``` bash
$ export HTTP_PROXY="http://192.168.10.100:8888"
$ export HTTPS_PROXY="https://192.168.10.100:8888"
```

### Switching Dynamically

If you want to change the proxy settings for an existing driver
instance, use the `driver.set_upstream_proxy` and
`driver.remove_upstream_proxy` methods:

``` python
driver.get(...)  # Using some initial proxy

# Change the upstream proxy
driver.set_upstream_proxy(ProxyConfig(https="https://user:pass@192.168.10.100:8888"))

driver.get(...)  # These requests will use the new proxy

# Remove the upstream proxy
driver.remove_upstream_proxy()
```

## All Options

A summary of all options that can be passed to Selenium Wire via the
`seleniumwire_options` webdriver attribute.

`host`

:   The IP address or hostname of the machine running Selenium Wire.
    This defaults to 127.0.0.1. You may want to change this to the
    public IP of the machine (or container) if you\'re using the [remote
    webdriver](#creating-the-webdriver).

``` python
options = SeleniumWireOptions(
    host="192.168.0.10"  # Use the public IP of the machine
)
driver = webdriver.Chrome(seleniumwire_options=options)
```

`port`

:   The port number that Selenium Wire\'s backend listens on. Defaults
    to 0, which selects an available port automatically.

`auto_config`

:   Whether Selenium Wire should auto-configure the browser for request
    capture. `True` by default.

`disable_capture`

:   Disable request capture. When `True` nothing gets intercepted or
    stored. `False` by default.

`disable_encoding`

:   Ask the server to send back uncompressed data. `False` by default.
    When `True` this sets the `Accept-Encoding` header to `identity` for
    all outbound requests. Note that it won\'t always work - sometimes
    the server may ignore it.

`enable_har`

:   When `True` a HAR archive of HTTP transactions will be kept which
    can be retrieved with `driver.har`. `False` by default.

`exclude_hosts`

:   A list of addresses for which Selenium Wire should be bypassed
    entirely. Note that if you have configured an upstream proxy then
    requests to excluded hosts will also bypass that proxy.

`ignore_http_methods`

:   A list of HTTP methods (specified as uppercase strings) that should
    be ignored by Selenium Wire and not captured. The default is
    `["OPTIONS"]` which ignores all OPTIONS requests. To capture all
    request methods, set `ignore_http_methods` to an empty list:

`request_storage`

:   The type of storage to use. Selenium Wire defaults to disk based
    storage, but you can switch to in-memory storage by setting this
    option to `memory`:

`request_storage_max_size`

:   The maximum number of requests to store when using in-memory
    storage. Unlimited by default. This option currently has no effect
    when using the default disk based storage.

`storage_base_dir`

:   The base location where Selenium Wire stores captured requests and
    responses when using its default disk based storage. This defaults
    to the home folder (that\'s `~/` on Linux/Mac and usually
    `C:\Users\<username>\` on Windows). A sub-folder called
    `.seleniumwire` will get created here to store the captured data and
    mitmproxy certificates.

`upstream_proxy`

: TODO

`verify_ssl`

:   Whether SSL certificates should be verified. `False` by default,
    which prevents errors with self-signed certificates.

`mitm_options`

:   Dictionary of options to pass to the underlying mitmproxy server.
    See <https://docs.mitmproxy.org/stable/concepts-options/>

## License

MIT. See the LICENSE file

[^1]: Selenium Wire ignores OPTIONS requests by default, as these are
    typically uninteresting and just add overhead. If you want to
    capture OPTIONS requests, you need to set the `ignore_http_methods`
    [option](#all-options) to `[]`.
[^2]: 3.13+ may have issues due to one of mitmproxy's upstream dependencies: https://github.com/mitmproxy/mitmproxy/issues/7127 - they say this shouldn't be a problem, though.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "selenium-wire-lw",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "selenium, archival, archiving, selenium-wire",
    "author": null,
    "author_email": "LunarWatcher <oliviawolfie@pm.me>",
    "download_url": "https://files.pythonhosted.org/packages/cc/07/a0f086dfa9937adcb5be67705175d9823354846f0ca79482c0a4ed03ca58/selenium_wire_lw-1.1.0.tar.gz",
    "platform": null,
    "description": "# Selenium Wire\n\nThis is a fork of 7x11x13's [selenium-wire-2](https://github.com/7x11x13/selenium-wire-2), which itself is a fork of Will Keeling's [selenium-wire](https://github.com/wkeeling/selenium-wire). This fork notably features both `undetected-geckodriver-lw` and `undetected-chromedriver` integration.\n\nThis fork exists because selenium-wire has been officially abandoned, selenium-wire-2 does not appear to be maintained, and I need selenium-wire for an archival project of mine, so here we go.\n\nSelenium Wire extends [Selenium\\'s](https://www.selenium.dev/documentation/en/) Python bindings to give you access to the underlying requests made by the browser. You author your code in the same way as you do with Selenium, but you get extra APIs for inspecting requests and responses and making changes to them on the fly.\n\n## Simple Example\n\n``` python\nfrom seleniumwire import webdriver  # Import from seleniumwire\n\n# Create a new instance of the Chrome driver\ndriver = webdriver.Chrome()\n\n# Go to the Google home page\ndriver.get(\"https://www.google.com\")\n\n# Access requests via the `requests` attribute\nfor request in driver.requests:\n    if request.response:\n        print(\n            request.url,\n            request.response.status_code,\n            request.response.headers[\"Content-Type\"]\n        )\n```\n\nPrints:\n\n```bash\nhttps://www.google.com/ 200 text/html; charset=UTF-8\nhttps://www.google.com/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png 200 image/png\nhttps://consent.google.com/status?continue=https://www.google.com&pc=s&timestamp=1531511954&gl=GB 204 text/html; charset=utf-8\nhttps://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png 200 image/png\nhttps://ssl.gstatic.com/gb/images/i2_2ec824b0.png 200 image/png\nhttps://www.google.com/gen_204?s=webaft&t=aft&atyp=csi&ei=kgRJW7DBONKTlwTK77wQ&rt=wsrt.366,aft.58,prt.58 204 text/html; charset=UTF-8\n...\n```\n\n## Features\n\n-   Pure Python, user-friendly API\n-   HTTP and HTTPS requests captured\n-   Intercept requests and responses\n-   Modify headers, parameters, body content on the fly\n-   Capture websocket messages\n-   HAR format supported\n-   Proxy server support\n\n## Compatibilty\n\n- Python 3.10+[^1]\n- Selenium 4.10.0+\n- Chrome, Firefox, Edge, Safari, and Remote Webdriver supported\n- `UndetectedFirefox` if `undetected-geckodriver-lw` is installed\n- `UndetectedChrome` if `undetected-chromedriver` is installed\n\n## Installation\n\nInstall using pip:\n\n``` bash\npip install selenium-wire-lw\n```\n\nIf you get an error about not being able to build cryptography you may\nbe running an old version of pip. Try upgrading pip with\n`python -m pip install --upgrade pip` and then re-run the above command.\n\nIn addition to the mainline install, three different variants are also supported:\n\n* `selenium-wire-lw[uf]`: `undetected-geckodriver-lw` is also installed\n* `selenium-wire-lw[uc]`: `undetected-chromedriver` is also installed\n* `selenium-wire-lw[ud]`: same as both `uf` and `uc`\n\n### Browser Setup\n\nNo specific configuration should be necessary except to ensure that you have downloaded the relevent webdriver executable for your browser and placed it somewhere on your system PATH.\n\n-   [Download](https://sites.google.com/chromium.org/driver/) webdriver for Chrome\n-   [Download](https://github.com/mozilla/geckodriver/) webdriver for Firefox\n-   [Download](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) webdriver for Edge\n\n> [!warning]\n>\n> If you're using `snap`, first, my sincerest condolences.\n>\n> You may need to `export SE_GECKODRIVER=/snap/bin/geckodriver` for Geckodriver to be correctly loaded. Chromedriver may have a similar problem with a similar solution, but I have never tried.\n\n### OpenSSL\n\nSelenium Wire requires OpenSSL for decrypting HTTPS requests. This is\nprobably already installed on your system (you can check by running\n`openssl version` on the command line). If it\\'s not installed you can\ninstall it with:\n\n**Linux**\n\n``` bash\n# For apt based Linux systems\nsudo apt install openssl\n\n# For RPM based Linux systems\nsudo yum install openssl\n\n# For Linux alpine\nsudo apk add openssl\n```\n\n**MacOS**\n\n``` bash\nbrew install openssl\n```\n\n**Windows**\n\nNo installation is required.\n\n### Certificates\n\nSee\n<https://docs.mitmproxy.org/stable/concepts-certificates/#the-mitmproxy-certificate-authority>\n\nThe CA certificate is stored in the directory specified by\n`storage_base_dir`.\n\n## Creating the Webdriver\n\nEnsure that you import `webdriver` from the `seleniumwire` package:\n\n``` python\nfrom seleniumwire import webdriver\n```\n\nThen just instantiate the webdriver as you would if you were using\nSelenium directly. You can pass in any desired capabilities or browser\nspecific options - such as the executable path, headless mode etc.\nSelenium Wire also has it\\'s [own options](#all-options) that can be\npassed in the `seleniumwire_options` attribute.\n\n``` python\n# Create the driver with no options (use defaults)\ndriver = webdriver.Chrome()\n\n# Or create using browser specific options and/or seleniumwire_options options\ndriver = webdriver.Chrome(\n    options = webdriver.ChromeOptions(...),\n    seleniumwire_options={...}\n)\n```\n\nNote that for sub-packages of `webdriver`, you should continue to import\nthese directly from `selenium`. For example, to import `WebDriverWait`:\n\n``` python\n# Sub-packages of webdriver must still be imported from `selenium` itself\nfrom selenium.webdriver.support.ui import WebDriverWait\n```\n\n**Remote Webdriver**\n\nSelenium Wire has limited support for using the remote webdriver client.\nWhen you create an instance of the remote webdriver, you need to specify\nthe hostname or IP address of the machine (or container) running\nSelenium Wire. This allows the remote instance to communicate back to\nSelenium Wire with its requests and responses.\n\n``` python\noptions = SeleniumWireOptions(\n    host=hostname_or_ip  # Address of the machine running Selenium Wire. Explicitly use 127.0.0.1 rather than localhost if remote session is running locally.\n)\ndriver = webdriver.Remote(\n    command_executor=\"http://www.example.com\",\n    seleniumwire_options=options\n)\n```\n\nIf the machine running the browser needs to use a different address to\ntalk to the machine running Selenium Wire you need to configure the\nbrowser manually. [This\nissue](https://github.com/wkeeling/selenium-wire/issues/220) goes into\nmore detail.\n\n## Accessing Requests\n\nSelenium Wire captures all HTTP/HTTPS traffic made by the browser[^1].\nThe following attributes provide access to requests and responses.\n\n`driver.requests`\n\n:   The list of captured requests in chronological order.\n\n`driver.last_request`\n\n:   Convenience attribute for retrieving the most recently captured\n    request. This is more efficient than using `driver.requests[-1]`.\n\n`driver.wait_for_request(pat, timeout=10)`\n\n:   This method will wait until it sees a request matching a pattern.\n    The `pat` attribute will be matched within the request URL. `pat`\n    can be a simple substring or a regular expression. Note that\n    `driver.wait_for_request()` doesn\\'t *make* a request, it just\n    *waits* for a previous request made by some other action and it will\n    return the first request it finds. Also note that since `pat` can be\n    a regular expression, you must escape special characters such as\n    question marks with a slash. A `TimeoutException` is raised if no\n    match is found within the timeout period.\n\n    For example, to wait for an AJAX request to return after a button is\n    clicked:\n\n    ``` python\n    # Click a button that triggers a background request to https://server/api/products/12345/\n    button_element.click()\n\n    # Wait for the request/response to complete\n    request = driver.wait_for_request(\"/api/products/12345/\")\n    ```\n\n`driver.har`\n\n:   A JSON formatted HAR archive of HTTP transactions that have taken\n    place. HAR capture is turned off by default and you must set the\n    `enable_har` [option](#all-options) to `True` before using\n    `driver.har`.\n\n`driver.iter_requests()`\n\n:   Returns an iterator over captured requests. Useful when dealing with\n    a large number of requests.\n\n`driver.request_interceptor`\n\n:   Used to set a request interceptor. See [Intercepting Requests and\n    Responses](#intercepting-requests-and-responses).\n\n`driver.response_interceptor`\n\n:   Used to set a response interceptor.\n\n**Clearing Requests**\n\nTo clear previously captured requests and HAR entries, use `del`:\n\n``` python\ndel driver.requests\n```\n\n## Request Objects\n\nRequest objects have the following attributes.\n\n`body`\n\n:   The request body as `bytes`. If the request has no body the value of\n    `body` will be empty, i.e. `b\"\"`.\n\n`certificate_list`\n\n:   Information about the server SSL certificates. Empty for non-HTTPS\n    requests.\n\n`date`\n\n:   The datetime the request was made.\n\n`headers`\n\n:   A dictionary-like object of request headers. Headers are\n    case-insensitive and duplicates are permitted. Asking for\n    `request.headers[\"user-agent\"]` will return the value of the\n    `User-Agent` header. If you wish to replace a header, make sure you\n    delete the existing header first with\n    `del request.headers[\"header-name\"]`, otherwise you\\'ll create a\n    duplicate.\n\n`host`\n\n:   The request host, e.g. `www.example.com`\n\n`method`\n\n:   The HTTP method, e.g. `GET` or `POST` etc.\n\n`params`\n\n:   A dictionary of request parameters. If a parameter with the same\n    name appears more than once in the request, it\\'s value in the\n    dictionary will be a list.\n\n`path`\n\n:   The request path, e.g. `/some/path/index.html`\n\n`querystring`\n\n:   The query string, e.g. `foo=bar&spam=eggs`\n\n`response`\n\n:   The [response object](#response-objects) associated with the\n    request. This will be `None` if the request has no response.\n\n`url`\n\n:   The request URL, e.g.\n    `https://www.example.com/some/path/index.html?foo=bar&spam=eggs`\n\n`ws_messages`\n\n:   Where the request is a websocket handshake request (normally with a\n    URL starting `wss://`) then `ws_messages` will contain a list of any\n    websocket messages sent and received. See [WebSocketMessage\n    Objects](#websocketmessage-objects).\n\nRequest objects have the following methods.\n\n`abort(error_code=403)`\n\n:   Trigger immediate termination of the request with the supplied error\n    code. For use within request interceptors. See [Example: Block a\n    request](#example-block-a-request).\n\n`create_response(status_code, headers=(), body=b\"\")`\n\n:   Create a response and return it without sending any data to the\n    remote server. For use within request interceptors. See [Example:\n    Mock a response](#example-mock-a-response).\n\n`decompress_body()` \n:   Returns the body decompressed with the method indicated by `Content-Encoding`. If this header is missing, it's assumed the body isn't compressed, and it's returned as-is\n\n### WebSocketMessage Objects\n\nThese objects represent websocket messages sent between the browser and\nserver and vice versa. They are held in a list by `request.ws_messages`\non websocket handshake requests. They have the following attributes.\n\n`content`\n\n:   The message content which may be either `str` or `bytes`.\n\n`date`\n\n:   The datetime of the message.\n\n`from_client`\n\n:   `True` when the message was sent by the client and `False` when sent\n    by the server.\n\n## Response Objects\n\nResponse objects have the following attributes.\n\n`body`\n\n:   The response body as `bytes`. If the response has no body the value\n    of `body` will be empty, i.e. `b\"\"`. Sometimes the body may have\n    been compressed by the server. You can prevent this with the\n    `disable_encoding` [option](#all-options). To manually decode an\n    encoded response body you can do:\n\n``` python\nfrom seleniumwire.utils import decode\n\nbody = decode(response.body, response.headers.get(\"Content-Encoding\", \"identity\"))\n```\n\n`date`\n\n:   The datetime the response was received.\n\n`headers`\n\n:   A dictionary-like object of response headers. Headers are\n    case-insensitive and duplicates are permitted. Asking for\n    `response.headers[\"content-length\"]` will return the value of the\n    `Content-Length` header. If you wish to replace a header, make sure\n    you delete the existing header first with\n    `del response.headers[\"header-name\"]`, otherwise you\\'ll create a\n    duplicate.\n\n`reason`\n\n:   The reason phrase, e.g. `OK` or `Not Found` etc.\n\n`status_code`\n\n:   The status code of the response, e.g. `200` or `404` etc.\n\nResponse objects have the following methods:\n\n`decompress_body()` \n:   Returns the body decompressed with the method indicated by `Content-Encoding`. If this header is missing, it's assumed the body isn't compressed, and it's returned as-is\n\n## Intercepting Requests and Responses\n\nAs well as capturing requests and responses, Selenium Wire allows you to\nmodify them on the fly using interceptors. An interceptor is a function\nthat gets invoked with requests and responses as they pass through\nSelenium Wire. Within an interceptor you can modify the request and\nresponse as you see fit.\n\nYou set your interceptor functions using the\n`driver.request_interceptor` and `driver.response_interceptor`\nattributes before you start using the driver. A request interceptor\nshould accept a single argument for the request. A response interceptor\nshould accept two arguments, one for the originating request and one for\nthe response.\n\n### Example: Add a request header\n\n``` python\ndef interceptor(request):\n    request.headers[\"New-Header\"] = \"Some Value\"\n\ndriver.request_interceptor = interceptor\ndriver.get(...)\n\n# All requests will now contain New-Header\n```\n\nHow can I check that a header has been set correctly? You can print the\nheaders from captured requests after the page has loaded using\n`driver.requests`, or alternatively point the webdriver at\n<https://httpbin.org/headers> which will echo the request headers back\nto the browser so you can view them.\n\n### Example: Replace an existing request header\n\nDuplicate header names are permitted in an HTTP request, so before\nsetting the replacement header you must first delete the existing header\nusing `del` like in the following example, otherwise two headers with\nthe same name will exist (`request.headers` is a special dictionary-like\nobject that allows duplicates).\n\n``` python\ndef interceptor(request):\n    del request.headers[\"Referer\"]  # Remember to delete the header first\n    request.headers[\"Referer\"] = \"some_referer\"  # Spoof the referer\n\ndriver.request_interceptor = interceptor\ndriver.get(...)\n\n# All requests will now use \"some_referer\" for the referer\n```\n\n### Example: Add a response header\n\n``` python\ndef interceptor(request, response):  # A response interceptor takes two args\n    if request.url == \"https://server.com/some/path\":\n        response.headers[\"New-Header\"] = \"Some Value\"\n\ndriver.response_interceptor = interceptor\ndriver.get(...)\n\n# Responses from https://server.com/some/path will now contain New-Header\n```\n\n### Example: Add a request parameter\n\nRequest parameters work differently to headers in that they are\ncalculated when they are set on the request. That means that you first\nhave to read them, then update them, and then write them back - like in\nthe following example. Parameters are held in a regular dictionary, so\nparameters with the same name will be overwritten.\n\n``` python\ndef interceptor(request):\n    params = request.params\n    params[\"foo\"] = \"bar\"\n    request.params = params\n\ndriver.request_interceptor = interceptor\ndriver.get(...)\n\n# foo=bar will be added to all requests\n```\n\n### Example: Update JSON in a POST request body\n\n``` python\nimport json\n\ndef interceptor(request):\n    if request.method == \"POST\" and request.headers[\"Content-Type\"] == \"application/json\":\n        # The body is in bytes so convert to a string\n        body = request.body.decode(\"utf-8\")\n        # Load the JSON\n        data = json.loads(body)\n        # Add a new property\n        data[\"foo\"] = \"bar\"\n        # Set the JSON back on the request\n        request.body = json.dumps(data).encode(\"utf-8\")\n        # Update the content length\n        del request.headers[\"Content-Length\"]\n        request.headers[\"Content-Length\"] = str(len(request.body))\n\ndriver.request_interceptor = interceptor\ndriver.get(...)\n```\n\n### Example: Basic authentication\n\nIf a site requires a username/password, you can use a request\ninterceptor to add authentication credentials to each request. This will\nstop the browser from displaying a username/password pop-up.\n\n``` python\nimport base64\n\nauth = (\n    base64.encodebytes(\"my_username:my_password\".encode())\n    .decode()\n    .strip()\n)\n\ndef interceptor(request):\n    if request.host == \"host_that_needs_auth\":\n        request.headers[\"Authorization\"] = f\"Basic {auth}\"\n\ndriver.request_interceptor = interceptor\ndriver.get(...)\n\n# Credentials will be transmitted with every request to \"host_that_needs_auth\"\n```\n\n### Example: Block a request\n\nYou can use `request.abort()` to block a request and send an immediate\nresponse back to the browser. An optional error code can be supplied.\nThe default is 403 (forbidden).\n\n``` python\ndef interceptor(request):\n    # Block PNG, JPEG and GIF images\n    if request.path.endswith((\".png\", \".jpg\", \".gif\")):\n        request.abort()\n\ndriver.request_interceptor = interceptor\ndriver.get(...)\n\n# Requests for PNG, JPEG and GIF images will result in a 403 Forbidden\n```\n\n### Example: Mock a response\n\nYou can use `request.create_response()` to send a custom reply back to\nthe browser. No data will be sent to the remote server.\n\n``` python\ndef interceptor(request):\n    if request.url == \"https://server.com/some/path\":\n        request.create_response(\n            status_code=200,\n            headers={\"Content-Type\": \"text/html\"},  # Optional headers dictionary\n            body=\"<html>Hello World!</html>\"  # Optional body\n        )\n\ndriver.request_interceptor = interceptor\ndriver.get(...)\n\n# Requests to https://server.com/some/path will have their responses mocked\n```\n\n*Have any other examples you think could be useful? Feel free to submit\na PR.*\n\n### Unset an interceptor\n\nTo unset an interceptor, use `del`:\n\n``` python\ndel driver.request_interceptor\ndel driver.response_interceptor\n```\n\n## Limiting Request Capture\n\nSelenium Wire works by redirecting browser traffic through an internal\nproxy server it spins up in the background. As requests flow through the\nproxy they are intercepted and captured. Capturing requests can slow\nthings down a little but there are a few things you can do to restrict\nwhat gets captured.\n\n`driver.include_urls` and `driver.exclude_urls`\n\n:   TODO This accepts a list of regular expressions that will match the\n    URLs to be captured. It should be set on the driver before making\n    any requests. When empty (the default) all URLs are captured.\n\n    ``` python\n    driver.include_urls = [\n        \".*stackoverflow.*\",\n        \".*github.*\"\n    ]\n\n    driver.get(...)  # Start making requests\n\n    # Only request URLs containing \"stackoverflow\" or \"github\" will now be captured\n    ```\n\n    ``` python\n    driver.exclude_urls = [\n        \".*stackoverflow.*\",\n        \".*github.*\"\n    ]\n\n    driver.get(...)  # Start making requests\n\n    # Only request URLs not containing \"stackoverflow\" or \"github\" will now be captured\n    ```\n\n    Note that even if a request is out of scope and not captured, it\n    will still travel through Selenium Wire.\n\n`seleniumwire_options.disable_capture`\n\n:   Use this option to switch off request capture. Requests will still\n    pass through Selenium Wire and through any upstream proxy you have\n    configured but they won\\'t be intercepted or stored. Request\n    interceptors will not execute.\n\n`seleniumwire_options.exclude_hosts`\n\n:   Use this option to bypass Selenium Wire entirely. Any requests made\n    to addresses listed here will go direct from the browser to the\n    server without involving Selenium Wire. Note that if you\\'ve\n    configured an upstream proxy then these requests will also bypass\n    that proxy.\n\n`request.abort()`\n\n:   You can abort a request early by using `request.abort()` from within\n    a [request interceptor](#intercepting-requests-and-responses). This\n    will send an immediate response back to the client without the\n    request travelling any further. You can use this mechanism to block\n    certain types of requests (e.g. images) to improve page load\n    performance.\n\n    ``` python\n    def interceptor(request):\n        # Block PNG, JPEG and GIF images\n        if request.path.endswith((\".png\", \".jpg\", \".gif\")):\n            request.abort()\n\n    driver.request_interceptor = interceptor\n\n    driver.get(...)  # Start making requests\n    ```\n\n## Request Storage\n\nCaptured requests and responses are stored in the home folder by default\n(that\\'s `~/` on Linux/Mac and usually `C:\\Users\\<username>` on Windows)\nin a sub-folder called `.seleniumwire`. To change where the\n`.seleniumwire` folder gets created you can use the `storage_base_dir`\noption:\n\n``` python\noptions = SeleniumWireOptions(\n    storage_base_dir=\"/my/storage/folder\"  # .seleniumwire will get created here\n)\ndriver = webdriver.Chrome(seleniumwire_options=options)\n```\n\n### In-Memory Storage\n\nSelenium Wire also supports storing requests and responses in memory\nonly, which may be useful in certain situations - e.g. if you\\'re\nrunning short lived Docker containers and don\\'t want the overhead of\ndisk persistence. You can enable in-memory storage by setting the\n`request_storage` option to `memory`:\n\n``` python\nfrom seleniumwire import SeleniumWireOptions\noptions = SeleniumWireOptions(request_storage=\"memory\")\ndriver = webdriver.Chrome(seleniumwire_options=options)\n```\n\nIf you\\'re concerned about the amount of memory that may be consumed,\nyou can restrict the number of requests that are stored with the\n`request_storage_max_size` option:\n\n``` python\nfrom seleniumwire import SeleniumWireOptions\noptions = SeleniumWireOptions(\n    request_storage=\"memory\",\n    request_storage_max_size=100  # Store no more than 100 requests in memory\n)\ndriver = webdriver.Chrome(seleniumwire_options=options)\n```\n\nWhen the max size is reached, older requests are discarded as newer\nrequests arrive. Keep in mind that if you restrict the number of\nrequests being stored, requests may have disappeared from storage by the\ntime you come to retrieve them with `driver.requests` or\n`driver.wait_for_request()` etc.\n\n## Upstream Proxies\n\nIf the site you are accessing sits behind a proxy server you can tell\nSelenium Wire about that proxy server in the options you pass to the\nwebdriver.\n\nThe configuration takes the following format:\n\n``` python\nfrom seleniumwire import ProxyConfig, SeleniumWireOptions\noptions = SeleniumWireOptions(\n    upstream_proxy=ProxyConfig(\n        http=\"http://192.168.10.100:8888\",\n        https=\"https://192.168.10.100:8888\"\n    )\n)\ndriver = webdriver.Chrome(seleniumwire_options=options)\n```\n\nTo use HTTP Basic Auth with your proxy, specify the username and\npassword in the URL:\n\n``` python\nfrom seleniumwire import ProxyConfig, SeleniumWireOptions\noptions = SeleniumWireOptions(\n    upstream_proxy=ProxyConfig(\n        https=\"https://user:pass@192.168.10.100:8888\"\n    }\n}\n```\n\nIf no upstream proxy config is supplied, seleniumwire uses the\n`HTTP_PROXY` and `HTTPS_PROXY` environment variables:\n\n``` bash\n$ export HTTP_PROXY=\"http://192.168.10.100:8888\"\n$ export HTTPS_PROXY=\"https://192.168.10.100:8888\"\n```\n\n### Switching Dynamically\n\nIf you want to change the proxy settings for an existing driver\ninstance, use the `driver.set_upstream_proxy` and\n`driver.remove_upstream_proxy` methods:\n\n``` python\ndriver.get(...)  # Using some initial proxy\n\n# Change the upstream proxy\ndriver.set_upstream_proxy(ProxyConfig(https=\"https://user:pass@192.168.10.100:8888\"))\n\ndriver.get(...)  # These requests will use the new proxy\n\n# Remove the upstream proxy\ndriver.remove_upstream_proxy()\n```\n\n## All Options\n\nA summary of all options that can be passed to Selenium Wire via the\n`seleniumwire_options` webdriver attribute.\n\n`host`\n\n:   The IP address or hostname of the machine running Selenium Wire.\n    This defaults to 127.0.0.1. You may want to change this to the\n    public IP of the machine (or container) if you\\'re using the [remote\n    webdriver](#creating-the-webdriver).\n\n``` python\noptions = SeleniumWireOptions(\n    host=\"192.168.0.10\"  # Use the public IP of the machine\n)\ndriver = webdriver.Chrome(seleniumwire_options=options)\n```\n\n`port`\n\n:   The port number that Selenium Wire\\'s backend listens on. Defaults\n    to 0, which selects an available port automatically.\n\n`auto_config`\n\n:   Whether Selenium Wire should auto-configure the browser for request\n    capture. `True` by default.\n\n`disable_capture`\n\n:   Disable request capture. When `True` nothing gets intercepted or\n    stored. `False` by default.\n\n`disable_encoding`\n\n:   Ask the server to send back uncompressed data. `False` by default.\n    When `True` this sets the `Accept-Encoding` header to `identity` for\n    all outbound requests. Note that it won\\'t always work - sometimes\n    the server may ignore it.\n\n`enable_har`\n\n:   When `True` a HAR archive of HTTP transactions will be kept which\n    can be retrieved with `driver.har`. `False` by default.\n\n`exclude_hosts`\n\n:   A list of addresses for which Selenium Wire should be bypassed\n    entirely. Note that if you have configured an upstream proxy then\n    requests to excluded hosts will also bypass that proxy.\n\n`ignore_http_methods`\n\n:   A list of HTTP methods (specified as uppercase strings) that should\n    be ignored by Selenium Wire and not captured. The default is\n    `[\"OPTIONS\"]` which ignores all OPTIONS requests. To capture all\n    request methods, set `ignore_http_methods` to an empty list:\n\n`request_storage`\n\n:   The type of storage to use. Selenium Wire defaults to disk based\n    storage, but you can switch to in-memory storage by setting this\n    option to `memory`:\n\n`request_storage_max_size`\n\n:   The maximum number of requests to store when using in-memory\n    storage. Unlimited by default. This option currently has no effect\n    when using the default disk based storage.\n\n`storage_base_dir`\n\n:   The base location where Selenium Wire stores captured requests and\n    responses when using its default disk based storage. This defaults\n    to the home folder (that\\'s `~/` on Linux/Mac and usually\n    `C:\\Users\\<username>\\` on Windows). A sub-folder called\n    `.seleniumwire` will get created here to store the captured data and\n    mitmproxy certificates.\n\n`upstream_proxy`\n\n: TODO\n\n`verify_ssl`\n\n:   Whether SSL certificates should be verified. `False` by default,\n    which prevents errors with self-signed certificates.\n\n`mitm_options`\n\n:   Dictionary of options to pass to the underlying mitmproxy server.\n    See <https://docs.mitmproxy.org/stable/concepts-options/>\n\n## License\n\nMIT. See the LICENSE file\n\n[^1]: Selenium Wire ignores OPTIONS requests by default, as these are\n    typically uninteresting and just add overhead. If you want to\n    capture OPTIONS requests, you need to set the `ignore_http_methods`\n    [option](#all-options) to `[]`.\n[^2]: 3.13+ may have issues due to one of mitmproxy's upstream dependencies: https://github.com/mitmproxy/mitmproxy/issues/7127 - they say this shouldn't be a problem, though.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Extends Selenium to give you the ability to inspect requests made by the browser, with built-in support for undetected-geckodriver-lw and undetected-chromedriver",
    "version": "1.1.0",
    "project_urls": {
        "Changelog": "https://github.com/LunarWatcher/selenium-wire/releases",
        "Documentation": "https://github.com/LunarWatcher/selenium-wire",
        "Homepage": "https://github.com/LunarWatcher/selenium-wire",
        "Issues": "https://github.com/LunarWatcher/selenium-wire/issues",
        "Repository": "https://github.com/LunarWatcher/selenium-wire.git"
    },
    "split_keywords": [
        "selenium",
        " archival",
        " archiving",
        " selenium-wire"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "97fe4b020104e3492867339cbce3266199419b73ee40073c26a4bda24924e798",
                "md5": "7881c97ed7b3d108a8460165eff1f2f9",
                "sha256": "8ad7e77817c05d9dcf077a0555ca6f3b5ba8e13eec4a25d9b9e67182d29d1dca"
            },
            "downloads": -1,
            "filename": "selenium_wire_lw-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7881c97ed7b3d108a8460165eff1f2f9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 31134,
            "upload_time": "2025-07-09T23:22:10",
            "upload_time_iso_8601": "2025-07-09T23:22:10.780048Z",
            "url": "https://files.pythonhosted.org/packages/97/fe/4b020104e3492867339cbce3266199419b73ee40073c26a4bda24924e798/selenium_wire_lw-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cc07a0f086dfa9937adcb5be67705175d9823354846f0ca79482c0a4ed03ca58",
                "md5": "3f4aa400d71c147f0e96ebeac48626dd",
                "sha256": "65d633eb9178e11021f0d4a91121885fdf73cae952621de4924c770da8c2e338"
            },
            "downloads": -1,
            "filename": "selenium_wire_lw-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3f4aa400d71c147f0e96ebeac48626dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 35879,
            "upload_time": "2025-07-09T23:22:12",
            "upload_time_iso_8601": "2025-07-09T23:22:12.355919Z",
            "url": "https://files.pythonhosted.org/packages/cc/07/a0f086dfa9937adcb5be67705175d9823354846f0ca79482c0a4ed03ca58/selenium_wire_lw-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-09 23:22:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LunarWatcher",
    "github_project": "selenium-wire",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "mitmproxy",
            "specs": [
                [
                    ">=",
                    "11.0.2"
                ]
            ]
        },
        {
            "name": "selenium",
            "specs": [
                [
                    ">=",
                    "4.10.0"
                ]
            ]
        },
        {
            "name": "brotli",
            "specs": [
                [
                    ">=",
                    "1.1.0"
                ]
            ]
        },
        {
            "name": "zstd",
            "specs": [
                [
                    ">=",
                    "1.5.7.2"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "httpbin",
            "specs": []
        }
    ],
    "lcname": "selenium-wire-lw"
}
        
Elapsed time: 0.41530s