Skip to content

Proxy Settings#

ProxySettings#

Class to configure the proxy as used in BrowserSettings.

Parameters:

Name Type Description Default
ip str

IP address of the proxy server. Should be an IPv4 address, e.g. 127.0.0.1.

required
port int

Port number of the proxy server, e.g. 8080.

required
type ProxyProtocol

Type of proxy protocol.

HTTP
username str | None

Username for the proxy server.

None
password str | None

Password for the proxy server.

None
Example

How to set a proxy server with a basic URL:

from browserist import Browser, BrowserSettings, ProxySettings

proxy_settings = ProxySettings(
    ip="127.0.0.1",
    port=8080)

settings = BrowserSettings(proxy=proxy_settings)

with Browser(settings) as browser:
    browser.open.url("https://example.com")

ProxyProtocol#

Class to define the type of proxy protocol as used in ProxySettings.

Attributes:

Name Type Description
ProxyProtocol.HTTP Enum

Use HTTP proxy.

ProxyProtocol.HTTPS Enum

Use HTTPS proxy.

ProxyProtocol.SOCKS4 Enum

Use SOCKS4 proxy.

ProxyProtocol.SOCKS5 Enum

Use SOCKS5 proxy.

Example

How to set a different proxy protocol than the default HTTP:

from browserist import Browser, BrowserSettings, ProxySettings, ProxyProtocol

proxy_settings = ProxySettings(
    ip="127.0.0.1",
    port=8080,
    protocol=ProxyProtocol.HTTPS)

settings = BrowserSettings(proxy=proxy_settings)

with Browser(settings) as browser:
    browser.open.url("https://example.com")