Skip to main content

A wrapper over Selenium Wire to provide Zyte Smart Proxy Manager specific functionalities.

Project description

Zyte SmartProxy Selenium

Use Selenium and Selenium Wire with Smart Proxy Manager easily!

A wrapper over Selenium Wire to provide Zyte Smart Proxy Manager specific functionalities.

QuickStart

  1. Install using pip
python3 -m pip install zyte-smartproxy-selenium

If you get an error about not being able to build cryptography you may be running an old version of pip. Try upgrading pip with python -m pip install --upgrade pip and then re-run the above command.

  1. Browser Setup

No specific configuration should be necessary except to ensure that you have downloaded the ChromeDriver and GeckoDriver for Chrome and Firefox to be remotely controlled, the same as if you were using Selenium directly. Once downloaded, these executables should be placed somewhere on your PATH.

  1. Create a file sample.py with the following content and replace <SPM_APIKEY> with your SPM Apikey
from zyte_smartproxy_selenium import webdriver

browser = webdriver.Chrome(spm_options={'spm_apikey': '<SPM_APIKEY>'})
browser.get('https://toscrape.com')
browser.save_screenshot('screenshot.png')
browser.close()

Make sure that you're able to make https requests using Smart Proxy Manager by following this guide Fetching HTTPS pages with Zyte Smart Proxy Manager

For sub-packages of webdriver, you should continue to import these directly from selenium or seleniumwire.

  1. Run sample.py using Python
python3 sample.py

API

Zyte SmartProxy Selenium extends Selenium Wire. You author your code in the same way as you do with Selenium Wire and Selenium, but you get extra spm_options argument with options specific for Zyte Smart Proxy Manager:

Argument Default Value Description
spm_apikey undefined Zyte Smart Proxy Manager API key that can be found on your zyte.com account.
spm_host http://proxy.zyte.com:8011 Zyte Smart Proxy Manager proxy host.
static_bypass true When true Zyte SmartProxy Selenium will skip proxy use for static assets defined by static_bypass_regex or pass false to use proxy.
static_bypass_regex /.*?\.(?:txt|json|css|less|js|mjs|cjs|gif|ico|jpe?g|svg|png|webp|mkv|mp4|mpe?g|webm|eot|ttf|woff2?)$/ Regex to use filtering URLs for static_bypass.
block_ads true When true Zyte SmartProxy Selenium will block ads defined by block_ads_lists.
block_ads_lists ['https://easylist.to/easylist/easylist.txt', 'https://easylist.to/easylist/easyprivacy.txt'] AdBlock lists to be used by Zyte SmartProxy Selenium to block ads
headers {'X-Crawlera-No-Bancheck': '1', 'X-Crawlera-Profile': 'pass', 'X-Crawlera-Cookies': 'disable'} List of headers to be appended to requests

Notes

Some websites may not work with block_ads and static_bypass enabled (default). Try to disable them if you encounter any issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Zyte SmartProxy Selenium-1.0.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

Zyte_SmartProxy_Selenium-1.0.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file Zyte SmartProxy Selenium-1.0.3.tar.gz.

File metadata

  • Download URL: Zyte SmartProxy Selenium-1.0.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.24.0 requests-toolbelt/0.9.1 urllib3/1.25.6 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

File hashes

Hashes for Zyte SmartProxy Selenium-1.0.3.tar.gz
Algorithm Hash digest
SHA256 31ef1f095ee943d3faa43cfc6c1154e264230d3e4090caf8e36a4e31b5d4f10c
MD5 4b5a080857c193c63ccecc0a78776ca8
BLAKE2b-256 3f5d3116ff3bf0f864ad848a4bb57699863fd619f983b1a04a23cd2e18cb7a79

See more details on using hashes here.

Provenance

File details

Details for the file Zyte_SmartProxy_Selenium-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: Zyte_SmartProxy_Selenium-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.24.0 requests-toolbelt/0.9.1 urllib3/1.25.6 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

File hashes

Hashes for Zyte_SmartProxy_Selenium-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ef54d548939d747a78b359303f21fd3bd6d3c2362f2933adcce82a9e728e2178
MD5 d91cc73b6fa8ede4bef4663be3ca378f
BLAKE2b-256 9afdcf124f743bbcf8c49bf49f6fbcf74bb0513188901e09de09e818d14c5f37

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page