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#
Install ChromeDriver for Chrome.
Download and install Zyte SmartProxy Selenium:
$ python3 -m pip install zyte-smartproxy-selenium
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()
Run
sample.py
with:$ python3 sample.py
Option 2 - Zyte SmartProxy Headless Proxy#
Setup the Zyte SmartProxy (formerly Crawlera) Headless Proxy as described in Using Headless Browsers with Zyte Smart Proxy Manager.
Install geckodriver for Firefox.
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