client
Package¶
-
class
browsermobproxy.
Client
(url, params=None, options=None)[source]¶ Initialises a new Client object
Parameters: - url – This is where the BrowserMob Proxy lives
- params – URL query (for example httpProxy and httpsProxy vars)
- options – Dictionary that can contain the port of an existing proxy to use (for example ‘existing_proxy_port_to_use’)
-
add_to_capabilities
(capabilities)[source]¶ Adds an ‘proxy’ entry to a desired capabilities dictionary with the BrowserMob proxy information
Parameters: capabilities – The Desired capabilities object from Selenium WebDriver
-
basic_authentication
(domain, username, password)[source]¶ This add automatic basic authentication
Parameters: - domain (str) – domain to set authentication credentials for
- username (str) – valid username to use when authenticating
- password (str) – valid password to use when authenticating
-
blacklist
(regexp, status_code)[source]¶ Sets a list of URL patterns to blacklist
Parameters: - regex (str) – a comma separated list of regular expressions
- status_code (int) – the HTTP status code to return for URLs that do not match the blacklist
-
har
¶ Gets the HAR that has been recorded
-
headers
(headers)[source]¶ This sets the headers that will set by the proxy on all requests
Parameters: headers (dict) – this is a dictionary of the headers to be set
-
limits
(options)[source]¶ Limit the bandwidth through the proxy.
Parameters: options (dict) – A dictionary with all the details you want to set. downstream_kbps - Sets the downstream kbps upstream_kbps - Sets the upstream kbps latency - Add the given latency to each HTTP request
-
new_har
(ref=None, options=None, title=None)[source]¶ This sets a new HAR to be recorded
Parameters: - ref (str) – A reference for the HAR. Defaults to None
- options (dict) –
A dictionary that will be passed to BrowserMob Proxy with specific keywords. Keywords are:
- captureHeaders: Boolean, capture headers
- captureContent: Boolean, capture content bodies
- captureBinaryContent: Boolean, capture binary content
- title (str) – the title of first har page. Defaults to ref.
-
new_page
(ref=None, title=None)[source]¶ This sets a new page to be recorded
Parameters: - ref (str) – A reference for the new page. Defaults to None
- title (str) – the title of new har page. Defaults to ref.
-
proxy_ports
¶ Return a list of proxy ports available
-
remap_hosts
(address=None, ip_address=None, hostmap=None)[source]¶ Remap the hosts for a specific URL
Parameters: - address (str) – url that you wish to remap
- ip_address (str) – IP Address that will handle all traffic for the address passed in
- **hostmap –
Other hosts to be added as keyword arguments
-
request_interceptor
(js)[source]¶ Executes the java/js code against each response HttpRequest request, HttpMessageContents contents, HttpMessageInfo messageInfo are available objects to interact with. :param str js: the js/java code to execute
-
response_interceptor
(js)[source]¶ Executes the java/js code against each response HttpRequest request, HttpMessageContents contents, HttpMessageInfo messageInfo are available objects to interact with. :param str js: the js/java code to execute
-
retry
(retry_count)[source]¶ Retries. No idea what its used for, but its in the API...
Parameters: retry_count (int) – the number of retries
-
rewrite_url
(match, replace)[source]¶ Rewrites the requested url.
Parameters: - match – a regex to match requests with
- replace – unicode a string to replace the matches with
-
timeouts
(options)[source]¶ Configure various timeouts in the proxy
Parameters: options (dict) – A dictionary with all the details you want to set. request - request timeout (in seconds) read - read timeout (in seconds) connection - connection timeout (in seconds) dns - dns lookup timeout (in seconds)