Skip to main content

A Scrapy extension that integrates with https://surfsky.io

Project description

scrapy-cloud-browser

PyPI - Version PyPI - Python Version

A Scrapy extension that integrates with surfsky.io for web scraping. This extension allows you to use Chrome anti-detection browsers through Surfsky.io's cloud browser service, helping you avoid detection while scraping challenging websites.


Installation

pip install scrapy-cloud-browser

Usage

Setup environment variables in settings.py in CLOUD_BROWSER namespace:

CLOUD_BROWSER = {
    "API_HOST": <HOST>,
    "API_TOKEN": <API_TOKEN>,
    "NUM_BROWSERS": <NUM_BROWSERS>,
    "PROXIES": [<proxy>],
    "PAGES_PER_BROWSER": <PAGES_PER_BROWSER>,
    "START_SEMAPHORES": <START_SEMAPHORES>,
    "PROXY_ORDERING": <PROXY_ORDERING>,
    "BROWSER_SETTINGS: <BROWSER_SETTINGS>,
    "FINGERPRINT": <FINGERPRINT>
}

Configuration Parameters

  • API_HOST: The URL of the Surfsky.io API host.
  • API_TOKEN: Your authentication token for the Surfsky.io service.
  • NUM_BROWSERS (default: 1): Number of browser instances to run in parallel. Increase this value to improve throughput for large-scale scraping.
  • PROXIES: A list of proxy URLs to use with the browsers. Each browser will be assigned a proxy from this list according to the PROXY_ORDERING strategy.
  • PAGES_PER_BROWSER (default: 100): Maximum number of pages a browser instance will process before being recycled.
  • START_SEMAPHORES (default: 10): Controls how many browsers can be started simultaneously. This prevents overwhelming the system with too many concurrent browser startups.
  • PROXY_ORDERING (default: 'random'): Strategy for assigning proxies to browsers. Options are:
    • 'random': Randomly select a proxy from the list for each browser
    • 'round-robin': Cycle through the proxy list in order

For detailed browser settings (BROWSER_SETTINGS) and fingerprint configuration options (FINGERPRINT), please refer to the Surfsky API Reference.

Add cloud browser handlers and change reactor in settings.py:

TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"

EXTENSIONS = {
    'scrapy_cloud_browser.CloudBrowserExtension': 100,
}

License

scrapy-cloud-browser is distributed under the terms of the MIT license.

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

scrapy_cloud_browser-0.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

scrapy_cloud_browser-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file scrapy_cloud_browser-0.1.0.tar.gz.

File metadata

  • Download URL: scrapy_cloud_browser-0.1.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for scrapy_cloud_browser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f60ad5320c6ac75612ee3733f54e2135134beca6729989d4b8935ecfc6c9c84
MD5 e669062a442ce7b147b3edafb3d63ca0
BLAKE2b-256 d372606aab2cee18991bc662df568be3c9e4434efeb5f8a7f3e7a877f1c4e365

See more details on using hashes here.

File details

Details for the file scrapy_cloud_browser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapy_cloud_browser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e315133f26dd93d23687f1b05f855f0029ead4eafa371ebeb9c21424c2c97da2
MD5 995a7c47b8cd55ee8f82635682ad8d86
BLAKE2b-256 1d767b3ed07597a874d3cebafc4861de07cd4c2cea87534b05085f18c818e0e8

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