How to Use Selenium with Bright Data
Integrate Bright Data proxies with Selenium in Python to enhance your automation workflows. This guide helps you set up secure, anonymous connections for web scraping and browser automation.
Expand to get your Bright Data Proxy Access Information
Expand to get your Bright Data Proxy Access Information
Your proxy access information
Bright Data proxies are grouped in “Proxy zones”. Each zone holds the configuration for the proxies it holds.
To get access to the proxy zone:
- Login to Bright Data control panel
- Select the proxy zone or setup a new one
- Click on the new zone name, and select the Overview tab.
- In the overview tab, under Access details you can find the proxy access details, and copy them to clipboard on click.
- You will need: Proxy Host, Proxy Port, Proxy Zone username and Proxy Zone password.
- Click on the copy icons to copy the text to your clipboard and paste in your tool’s proxy configuration.
Access Details Section Example
Residential proxy access
To access Bright Data’s Residential Proxies you will need to either get verified by our compliance team, or install a certificate. Read more…
Targeting search engines?
If you target a search engine like google, bing or yandex, you need a special Search Engine Results Page (SERP) proxy API. Use Bright Data SERP API to target search engines. Click here to read more about Bright Data SERP proxy API.
Correct setup of proxy test to avoid “PROXY ERROR”
In many tools you will see a “test proxy” function, which performs a conncectivity test to your proxy, and some add a geolocation test as well, to identify the location of the proxy.
To correctly test your proxy you should target those search queries to:
https://geo.brdtest.com/welcome.txt
.
Some tools use popular search engines (like google.com) as a default test target. Bright Data will block those requests and you tool will show proxy error although your proxy is perfectly fine.
If your proxy test fails, this is probably the reason. Make sure that your test domain is not a search engine (this is done in the tool configuration, and not controlled by Bright Data).
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.
Maintain a consistent IP throughout your browser session by using the -session
parameter in your username. This is essential because BrightData proxies default to rotating IPs with each request. Learn more
New users should begin with ISP or Data Center proxies, as residential proxies are incompatible with browser integration in Immediate-Access mode .
For use-cases related to account management, use a consistent static dedicated IP for each account you are managing. dedicated ISP proxies should be used for this.
How to Integrate Bright Data 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
3. Bright Data Proxy details: Obtain your proxy details (host, port, username, password) from the Bright Data 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:
Step 1. Import Required Libraries
Start by importing the necessary modules:
Step 2. Configure Your Bright Data Proxy
Set up your Bright Data proxy credentials and construct the proxy server URL:
Step 3. Set Up Chrome Options
Use the Selenium ChromeOptions to configure the proxy:
Step 4: Initialize the WebDriver
Specify the path to your ChromeDriver and initialize the WebDriver with the proxy settings:
Step 5: Test the Proxy
Use Selenium to navigate to a test URL and verify the proxy is working:
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:
By integrating Bright Data 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, Bright Data ensures reliability and privacy for all your automation needs. Start building smarter workflows with Bright Data and Selenium today!