Selenium is a browser automation tool. This particular repository only covers Selenium setup for the Python programming language.
To continue further development with this tool, read the official Selenium documentation for Python.
Unfortunately, Selenium itself doesn't support username:password
authentication for HTTP/HTTPs
proxies; therefore, you'll need to have your IP whitelisted.
You can do that by following the guidelines listed here.
Once you have all of the prerequisites ready, open the Terminal/Command Prompt window and create your project folder:
mkdir your_project
When the project directory is set up, you can download the script example.py:
- Navigate to the main directory of your project folder using
cd your_project
- Download the script using the following command:
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/python/example.py > example.py
The only configuration required for the script are the values below:
HOSTNAME = ''
PORT = ''
DRIVER = ''
You can get the HOSTNAME
and PORT
information from the Smartproxy dashboard.
The configuration for the DRIVER
value can be either 'CHROME' or 'FIREFOX'. This will determine if 'chromedriver' or 'geckodriver' will be installed and used during the process.
The script consists of two functions:
smartproxy()
– handles the proxy authentication;webdriver_example()
– installs the required drivers and gets a response from the target. In this case, the target ishttp://ip.smartproxy.com/
.
browser.get('http://ip.smartproxy.com/')
Note that Chrome and Firefox have different attributes for proxy authentication; therefore, your requests should be similar to the following:
Firefox
browser = webdriver.Firefox(service=Service(GeckoDriverManager().install()), proxy=smartproxy())
Chrome
browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), desired_capabilities=smartproxy())
Before proceeding with the testing, you'll need to install the webdriver_manager
using the command below:
pip3 install webdriver_manager
To run the script, simply execute the python3 example.py
command while in your project's directory.
For machines running Windows, execute the python example.py
command instead.
Email - sales@smartproxy.com
Live chat 24/7