< Back

How to connect to Goproxies proxy via 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 Wire to extend Selenium's Python bindings, since using the default Selenium module for implementing proxies that require authentication makes it complicated. You can do it using the pip command:

pip install selenium-wire
  • 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 the webdriver-manager using the pip command as well:

pip install webdriver-manager
  • 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-america.goproxies.com:10000'

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

from selenium.webdriver.common.by import By
from seleniumwire import webdriver
# A package to have a chromedriver always up-to-date.
from webdriver_manager.chrome import ChromeDriverManager

USERNAME = "your_username"
PASSWORD = "your_password"
ENDPOINT = "proxy-america.goproxies.com:10000"
def chrome_proxy(user: str, password: str, endpoint: str) -> dict:
    wire_options = {
        "proxy": {
            "http": f"http://{user}:{password}@{endpoint}",
            "https": f"http://{user}:{password}@{endpoint}",
        }
    }
    return wire_options
    
def execute_driver():
    options = webdriver.ChromeOptions()
    options.headless = True
    proxies = chrome_proxy(USERNAME, PASSWORD, ENDPOINT)
    driver = webdriver.Chrome(
        ChromeDriverManager().install(), options=options, seleniumwire_options=proxies
    )
    try:
        driver.get("https://ip.goproxies.com/")
        return f'\nYour IP is: {driver.find_element(By.CSS_SELECTOR, "body").text}'
    finally:
        driver.quit()

if __name__ == "__main__":
    print(execute_driver())

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

By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.