scrapy-playwright-cloud-browser
A Scrapy extension that integrates with surfsky.io for web scraping using Playwright. This extension allows you to use Chrome anti-detection browsers through Surfsky.io's cloud browser service with Playwright integration, helping you avoid detection while scraping challenging websites.
Installation
pip install scrapy-playwright-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>],
"INIT_HANDLER": <INIT_HANDLER>,
"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.
- INIT_HANDLER: Custom initialization handler for browser setup.
- 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_playwright_cloud_browser.CloudBrowserExtension': 100,
}
License
scrapy-playwright-cloud-browser is distributed under the terms of the MIT license.
Release files for scrapy-playwright-cloud-browser 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| scrapy_playwright_cloud_browser-0.1.2.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scrapy_playwright_cloud_browser-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.0 kB
Release files / scrapy_playwright_cloud_browser-0.1.2.tar.gz
| Download URL | scrapy_playwright_cloud_browser-0.1.2.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8262f1e892f73a2bb700b5e1fb73911756d82bb9a5e805908c59beebe10fb0c
|
|
BLAKE2b-256 checksum How to use checksums |
8c0cdc938eab71eab3444392cf859c996501082178b9d06d7c7d3d185644e69c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / scrapy_playwright_cloud_browser-0.1.2-py3-none-any.whl
| Download URL | scrapy_playwright_cloud_browser-0.1.2-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22cff0e18119cd6ea1bb5d3f75e258963fcb55e537cb2f96e9a728b7be58f192
|
|
BLAKE2b-256 checksum How to use checksums |
1a473d3965942172862cb0a80256b6c679f9ea02373a0dfa20425ab6b92687ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|