Skip to content

Selenium Integration

Selenium

This tutorial uses the Python web scraping framework Selenium.

Step 1: Install the library

shell
pip install selenium selenium-wire webdriver-manager

Step 2: Retrieve CA certificate and project credentials

Certificate

  1. Open Scrapoxy User interface, and go to the project Settings;
  2. Enable Keep the same proxy with cookie injection;
  3. Click on Download CA certificate and save the file.
  4. Remember the project's Username;
  5. Remember the project's Password.

INFO

It is assumed that file is saved in /tmp/scrapoxy-ca.crt.

Step 3: Create and run the script

Create a file name selenium.py with the following content:

python
from seleniumwire import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By

driver = webdriver.Chrome(
    seleniumwire_options={
        'proxy': {
            'http': f'http://USERNAME:PASSWORD@localhost:8888',
            'verify_ssl': True,
            'ca_cert': '/tmp/scrapoxy-ca.crt',
        },
    }
)

driver.get('https://fingerprint.scrapoxy.io')

print(driver.find_element(By.TAG_NAME, 'body').text)

Replace USERNAME and PASSWORD by the credentials you copied earlier.

INFO

All requests made in the same session will use the same proxy instance.

Run the script:

shell
python selenium.py

Released under the MIT License.