Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Server
✓ from browsermobproxy import Server
✗ import browsermobproxy.Server
Incorrect: 'browsermobproxy.Server' is not a module; use from ... import syntax
Client
✓ from browsermobproxy import Client
Start Browsermob Proxy, integrate with Selenium, capture HAR data.
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()
Errors
Common errors & fixes
browsermobproxy.exceptions.ProxyNotFoundError: The browsermob proxy executable was not found. Please specify the path to the executable.
The library cannot find the Browsermob Proxy binary. Either the path is incorrect or the binary is not installed.
fixProvide correct path to 'browsermob-proxy' binary: Server('/usr/local/bin/browsermob-proxy') or set PATH. AttributeError: module 'browsermobproxy' has no attribute 'Server'
Incorrect import statement; often from copy-paste of wrong syntax.
fixUse 'from browsermobproxy import Server'
Upgrade
Version history
0.8.0latest on PyPI · released Feb 7, 2017
Audit
Dependencies
requestsrequiredHTTP client for API calls to Browsermob Proxy REST API
seleniumoptionalOften used together for browser automation with proxy integration