Content-Length: 262143 | pFad | https://github.com/Smartproxy/Selenium/tree/master/python

51 Selenium/python at master · Smartproxy/Selenium · GitHub
Skip to content

Latest commit

 

History

History

python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Smartproxy logo

🏠 Main Repository 🏠

Disclaimer

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.

Prerequisites

Installation

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:

  1. Navigate to the main directory of your project folder using cd your_project
  2. Download the script using the following command: curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/python/example.py > example.py

3. Your project folder should now be populated with the *example.py* file.

Configuration

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.

Usage

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 is http://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())

Testing

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.

Need help?

Email - sales@smartproxy.com
Live chat 24/7









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/Smartproxy/Selenium/tree/master/python

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy