Browsermob Proxy Python Client
raw JSON → 0.8.0 verified Sat May 09 auth: no python maintenance
A Python client library for interacting with the Browsermob Proxy, used for capturing HTTP/HTTPS traffic in HAR format. Current version 0.8.0, last released in 2015, now in maintenance mode.
pip install browsermob-proxy Common errors
error browsermobproxy.exceptions.ProxyNotFoundError: The browsermob proxy executable was not found. Please specify the path to the executable. ↓
cause The library cannot find the Browsermob Proxy binary. Either the path is incorrect or the binary is not installed.
fix
Provide correct path to 'browsermob-proxy' binary: Server('/usr/local/bin/browsermob-proxy') or set PATH.
error AttributeError: module 'browsermobproxy' has no attribute 'Server' ↓
cause Incorrect import statement; often from copy-paste of wrong syntax.
fix
Use 'from browsermobproxy import Server'
Warnings
deprecated Library is unmaintained since 2015. Browsermob Proxy itself has been discontinued. Consider migrating to BrowserUp Proxy (browserup-proxy) which is the actively maintained fork. ↓
fix Use browserup-proxy Python package instead: pip install browserup-proxy and update import to 'from browserup_proxy import Server'
gotcha The library requires a running Browsermob Proxy Java binary. It does not start the proxy automatically; you must provide the path to the browsermob-proxy executable or use the local=True flag for it to download and start a local instance (only works if the binary is not present). ↓
fix Ensure the Browsermob Proxy binary is installed or use the 'local=True' parameter in Server() to auto-download (may fail on some systems).
gotcha The 'create_proxy' method may return a Client object that uses requests.Session; if you close the session prematurely, subsequent calls fail. Always use proxy.close() to clean up. ↓
fix Call proxy.close() after finishing, not client.session.close().
Imports
- Server wrong
import browsermobproxy.Servercorrectfrom browsermobproxy import Server - Client
from browsermobproxy import Client
Quickstart
from browsermobproxy import Server
from selenium import webdriver
# Start Browsermob Proxy server
server = Server('/path/to/browsermob-proxy')
server.start()
proxy = server.create_proxy()
# Configure Selenium to use proxy
from selenium.webdriver.common.proxy import Proxy, ProxyType
selenium_proxy = Proxy()
selenium_proxy.proxy_type = ProxyType.MANUAL
selenium_proxy.http_proxy = proxy.proxy
selenium_proxy.ssl_proxy = proxy.proxy
capabilities = webdriver.DesiredCapabilities.CHROME
proxy.add_to_capabilities(capabilities)
driver = webdriver.Chrome(desired_capabilities=capabilities)
# Enable HAR capture
proxy.new_har('test')
driver.get('http://example.com')
# Get HAR data
har = proxy.har
print(har)
# Cleanup
driver.quit()
server.stop()