Skip to main content

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

Project description

Zyte SmartProxy Selenium

made-with-javascript npm

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.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: Zyte SmartProxy Selenium-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 b7bb1541bc4ecd62d8c215678399e055f6dc8d4d214050f83f3e0ec8230ecb40
MD5 a870735d1e490fa695374a388f2f1618
BLAKE2b-256 9bc7ff922a3a954f06f79425c111bf7b6db6bf688c6f985cb42747a52d54520a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Zyte_SmartProxy_Selenium-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca77d09d0c43d985900c3f69074339a492a7f457346193c743b1d5297c34f8a
MD5 214f26f3a77f6824ca30b4ce4aca5256
BLAKE2b-256 c297b4130148021e78638172e7af7f9093f5adcf1b8cb630a190a034c1ef1dd1

See more details on using hashes here.

Supported by

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