Selenium

How to connect to GoProxies using Selenium

Selenium is a tool that helps automate web browser interactions for website testing and more.

To integrate Selenium with GoProxies, you would need to follow the steps below:

  • Firstly, you would need to install Selenium Wirearrow-up-right to extend Selenium's Python bindings, since using the default Selenium module for implementing proxies that require authentication makes it complicated.

  • Another package which is recommended for this integration is webdriver-manager. It's a package that simplifies the management of binary drivers for different browsers. In this case, there's no need to manually download a new version of a web driver after each update.

You can install both packages using the following command:

pip install selenium selenium-wire webdriver-manager
circle-info

Note: if using Python 3.13 and you encounter a blinker._saferef error, install:

pip install blinker==1.6.2
  • Specify your account credentials for proxies to work:

    • Firstly, you would need to replace 'your_username' and 'your_password' with your credentials.

    • Then you need to specify the endpoint, in this example we're using 'proxy.goproxies.com:1080'

  • The full example of a code should look like this:

from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from seleniumwire import webdriver
from webdriver_manager.chrome import ChromeDriverManager

# =========================
# Replace with your details
# =========================
USERNAME = "customer-your_username"
PASSWORD = "your_password"
ENDPOINT = "proxy.goproxies.com:1080"
# =========================


def get_proxy_options(user: str, password: str, endpoint: str) -> dict:
    return {
        "proxy": {
            "http": f"http://{user}:{password}@{endpoint}",
            "https": f"http://{user}:{password}@{endpoint}",
        }
    }


def create_driver():
    chrome_options = webdriver.ChromeOptions()

    # Visible browser is recommended for testing
    # Uncomment the line below if you want headless mode
    # chrome_options.add_argument("--headless=new")

    chrome_options.add_argument("--window-size=1920,1080")
    chrome_options.add_argument("--no-sandbox")
    chrome_options.add_argument("--disable-dev-shm-usage")

    # Optional: reduce page load hanging on heavy JS sites
    chrome_options.page_load_strategy = "eager"

    service = Service(ChromeDriverManager().install())

    driver = webdriver.Chrome(
        service=service,
        options=chrome_options,
        seleniumwire_options=get_proxy_options(USERNAME, PASSWORD, ENDPOINT),
    )

    return driver


def test_proxy():
    driver = create_driver()

    try:
        driver.get("https://ip.goproxies.com/")
        ip = driver.find_element(By.TAG_NAME, "body").text.strip()
        print(f"Your IP is: {ip}")

    finally:
        driver.quit()


if __name__ == "__main__":
    test_proxy()

That's it! You've set-up GoProxies via Selenium.

Now run the script by entering the following into your command prompt where the python file is located:

If configured correctly, the script will print the residential IP assigned by GoProxies.

circle-info
  • This example uses an HTTP proxy endpoint (:1080)

  • For SOCKS5 proxies, use port 10003 and change the scheme to socks5:// .

  • Some websites apply advanced bot mitigation. In such cases, using a full browser automation framework (Selenium, Playwright) is recommended over direct HTTP libraries like python's requests.

Last updated

Was this helpful?