Warning

Zyte API is replacing Smart Proxy Manager. See Migrating from Smart Proxy Manager to Zyte API.

Using Smart Proxy Manager with Selenium Wire#

Warning

For the code below to work you must first install the Zyte CA certificate.

Note

Selenium Wire requires Selenium python libraries, WebDriver installed and an active Smart Proxy Manager account. Log in here.

Note

All the code in this documentation has been tested with Geckodriver 0.30.0, Python 3.9.5 and selenium-wire 4.5.4.

Option 1 - Zyte SmartProxy Selenium#

  1. Install ChromeDriver for Chrome.

  2. Download and install Zyte SmartProxy Selenium:

    $ python3 -m pip install zyte-smartproxy-selenium
    
  3. Save the following code as a sample.py:

from zyte_smartproxy_selenium import webdriver

browser = webdriver.Chrome(spm_options={'spm_apikey': '<Smart Proxy Manager API KEY>'})
browser.get('https://toscrape.com')
browser.save_screenshot('screenshot.png')
browser.close()
  1. Run sample.py with:

    $ python3 sample.py
    

Option 2 - Zyte SmartProxy Headless Proxy#

  1. Setup the Zyte SmartProxy (formerly Crawlera) Headless Proxy as described in Using Headless Browsers with Zyte Smart Proxy Manager.

  2. Install geckodriver for Firefox.

  3. Save the following code as a sample.py:

from seleniumwire import webdriver

headless_proxy = "http://127.0.0.1:3128"
seleniumwire_options = {
    "proxy": {"http": headless_proxy, "https": headless_proxy, "no_proxy": ""}
}
browser = webdriver.Firefox(seleniumwire_options=seleniumwire_options)
browser.get("https://toscrape.com")
browser.save_screenshot("screenshot.png")
browser.close()

4. Install Selenium Wire and run sample.py with:

$ pip install selenium-wire
$ python3 sample.py