{"library":"selenium-wire","title":"Selenium Wire","description":"Selenium Wire is a lightweight Python package that extends Selenium's WebDriver functionality, providing advanced capabilities to access and manipulate underlying network requests made by the browser. It acts as a proxy server, intercepting and logging all HTTP/HTTPS traffic in real time. Developers can use its APIs to monitor, modify, inspect, or block requests and responses during web automation and scraping. The library is currently at version 5.1.0 and is actively used and maintained, compatible with Python 3.7+ and Selenium 4.0.0+.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install selenium-wire"],"cli":null},"imports":["from seleniumwire import webdriver","from selenium.webdriver.chrome.options import Options"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom seleniumwire import webdriver\nfrom selenium.webdriver.chrome.options import Options\n\n# Configure Chrome options (e.g., headless mode)\nchrome_options = Options()\n# chrome_options.add_argument('--headless')\n\n# Configure Selenium Wire options (e.g., disable capture to start)\n# For proxy with authentication, use env vars or direct string:\n# PROXY_HOST = os.environ.get('PROXY_HOST', 'your_proxy_host')\n# PROXY_PORT = os.environ.get('PROXY_PORT', '8080')\n# PROXY_USER = os.environ.get('PROXY_USER', 'your_proxy_username')\n# PROXY_PASS = os.environ.get('PROXY_PASS', 'your_proxy_password')\n# seleniumwire_options = {\n#     'proxy': {\n#         'http': f'http://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}',\n#         'https': f'https://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}',\n#         'no_proxy': 'localhost,127.0.0.1'\n#     }\n# }\n\n# Create a new instance of the Chrome driver with Selenium Wire\ndriver = webdriver.Chrome(options=chrome_options, seleniumwire_options={'disable_capture': False})\n\ntry:\n    # Go to a webpage\n    driver.get('https://www.google.com')\n\n    # Access requests via the `requests` attribute\n    print('Captured Requests:')\n    for request in driver.requests:\n        if request.response:\n            print(f'URL: {request.url}, Status: {request.response.status_code}, Content-Type: {request.response.headers.get(\"Content-Type\")}')\n\n    # Example: Intercept a request to add a header\n    def interceptor(request):\n        if request.url == 'https://www.google.com/':\n            request.headers['X-Custom-Header'] = 'SeleniumWireTest'\n\n    driver.request_interceptor = interceptor\n    driver.get('https://httpbin.org/headers') # Navigate to a site that echoes headers\n    print('\\nIntercepted Request to httpbin.org/headers:')\n    for request in driver.requests:\n        if 'httpbin.org/headers' in request.url and request.response:\n            print(f'URL: {request.url}, Status: {request.response.status_code}')\n            # For demonstration, typically you'd parse response.body to confirm header\n            print('Response body snippet (may contain X-Custom-Header if successfully applied):')\n            try:\n                print(request.response.body.decode('utf-8')[:200] + '...')\n            except Exception as e:\n                print(f'Could not decode response body: {e}')\n\nfinally:\n    # Close the browser\n    driver.quit()","lang":"python","description":"This quickstart demonstrates how to initialize a Selenium Wire WebDriver for Chrome, navigate to a page, and then iterate through the captured network requests and their responses. It also includes an example of setting a request interceptor to modify headers for a specific URL, showing how to gain programmatic control over network traffic. Remember to have a compatible browser driver (e.g., ChromeDriver) installed and accessible in your system PATH or specified via `executable_path`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"5.1.0","pypi_latest":"5.1.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":5.4,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"94.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.5,"import_time_s":null,"mem_mb":null,"disk_size":"104M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"101.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.4,"import_time_s":null,"mem_mb":null,"disk_size":"111M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"91.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.9,"import_time_s":null,"mem_mb":null,"disk_size":"101M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"90.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.1,"import_time_s":null,"mem_mb":null,"disk_size":"101M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"93.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"selenium-wire","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":6.1,"import_time_s":null,"mem_mb":null,"disk_size":"104M"}]}}