What is Selenium?

Selenium is a powerful, open-source tool for automating web browsers. It supports multiple programming languages, including JavaScript, Python, and Java, and provides a robust API for controlling browser actions. Selenium is widely used for web scraping, automated testing, and browser-based workflows. With its flexibility and cross-browser compatibility, it’s an essential tool for developers and testers alike.

How to Integrate Toolip With Selenium

Step 0. Prerequisites

Before starting, make sure you have:

1. Python installed: Download the latest version from python.org.

2. Install Selenium: Use pip to install the Selenium library

pip install selenium

3. Toolip Proxy details: Obtain your proxy details (host, port, username, password) from the Toolip dashboard.

4. WebDriver Installed: Obtain the appropriate WebDriver for your browser of choice (e.g., ChromeDriver for Google Chrome).

  • For easier driver setup, consider using the webdriver-manager package:
pip install webdriver-manager

Step 1. Import Required Libraries

Start by importing the necessary modules:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

Step 2. Configure Your Toolip Proxy

Set up your Toolip proxy credentials and construct the proxy server URL:

# Toolip Proxy Configuration
proxy_host = "proxy.toolip.io"
proxy_port = "port"  # Replace with your port number
proxy_username = "username"  # Replace with your Toolip username
proxy_password = "password"  # Replace with your Toolip password

# Full Proxy URL
proxy = f"http://{proxy_username}:{proxy_password}@{proxy_host}:{proxy_port}"

Step 3. Set Up Chrome Options

Use the Selenium ChromeOptions to configure the proxy:

# Configure Chrome Options
chrome_options = Options()
chrome_options.add_argument(f"--proxy-server={proxy}")

Step 4: Initialize the WebDriver

Specify the path to your ChromeDriver and initialize the WebDriver with the proxy settings:

# Initialize WebDriver
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)

Step 5: Test the Proxy

Use Selenium to navigate to a test URL and verify the proxy is working:

    # Navigate to a test site
    print("Connecting to target website...")
    driver.get("http://httpbin.org/ip")

    # Print the page content
    print("Page content:")
    print(driver.page_source)

    # Close the browser
    driver.quit()

Step 6. Verify the Output

When running the script, the IP address used by the proxy will be displayed in the browser or printed to the console. Example output:

{
  "origin": "123.45.67.89"
}

By integrating Toolip proxies with Selenium, you can automate web interactions securely and efficiently. Whether you’re testing web applications, scraping dynamic content, or navigating geo-restricted websites, Toolip ensures reliability and privacy for all your automation needs. Start building smarter workflows with Toolip and Selenium today!