Scrapely Python Client
The official Python client for Scrapely.io, a powerful API for web scraping and CAPTCHA solving.
Features
- Web Crawling: Scrape websites with advanced options like screenshotting, resource blocking, and custom instructions (click, scroll, type, wait).
- CAPTCHA Solving: Solve Google reCAPTCHA (V2/V3) and Cloudflare Turnstile/Challenge.
- Async Support: Fully asynchronous client (
AsyncScrapely) for high-concurrency applications. - Typed Responses: All API responses are returned as typed Python objects for better IDE support and type safety.
Installation
pip install scrapely-python-client
Usage
Synchronous Client
from scrapely import Scrapely
client = Scrapely(api_key="YOUR_API_KEY")
# 1. Crawl a website
response = client.crawler.crawl(
website_url="https://example.com",
return_page_text=True
)
print(response.result.text)
# 2. Solve reCAPTCHA V3
captcha = client.google.RecaptchaV3(
website_url="https://example.com",
website_key="6LdKlZEpAAAAAAOQjzC2v_d36tWxCl6dWsozdSy9"
)
print(captcha.result.solution)
Asynchronous Client
import asyncio
from scrapely import AsyncScrapely
async def main():
client = AsyncScrapely(api_key="YOUR_API_KEY")
# 1. Crawl a website asynchronously
response = await client.crawler.crawl(
website_url="https://example.com",
screenshot=True
)
print(f"Screenshot URL: {response.result.screenshot}")
# 2. Solve Cloudflare Turnstile asynchronously
captcha = await client.cloudflare.Turnstile(
website_url="https://example.com",
website_key="0x4AAAAAA..."
)
print(f"Token: {captcha.result.solution}")
if __name__ == "__main__":
asyncio.run(main())
Advanced Usage
Automation Instructions
You can pass a list of instructions to interact with the page before scraping.
from scrapely import Scrapely
from scrapely.models.types import SendKeys, Click, Wait
client = Scrapely(api_key="YOUR_API_KEY")
instructions = [
SendKeys(selector="#search", text="scraping"),
Click(selector="#submit-button"),
Wait(timeout=2) # Wait 2 seconds
]
response = client.crawler.crawl(
website_url="https://example.com",
instructions=instructions,
return_page_text=True
)
Response Objects
Responses are typed dataclasses:
CrawlerResponse: Containsresult(CrawlerResult) with fields likehtml,text,cookies,screenshot.CaptchaResponse: Containsresult(CaptchaResult) with thesolutionstring.
License
MIT
Metadata
Release files for scrapely-python-client 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| scrapely_python_client-0.1.3.tar.gz | 12.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scrapely_python_client-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.0 kB
Release files / scrapely_python_client-0.1.3.tar.gz
| Download URL | scrapely_python_client-0.1.3.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7740b1caecf44ed6485b2393ac214a56ea95a75228ac3f8be98cb4a9fab28a7
|
|
BLAKE2b-256 checksum How to use checksums |
e1bc138abfeb204632702153db9a67d847a62fc2e4d9ca12797aca96e77a72b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|
Release files / scrapely_python_client-0.1.3-py3-none-any.whl
| Download URL | scrapely_python_client-0.1.3-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df2540ce91ea798db051f33e6dbaab2a86e147bb1c2debb8f55710bb7df86251
|
|
BLAKE2b-256 checksum How to use checksums |
98b548420f3d8e2651516a7c00f7fc1f6be85cd2b060b69d49c7fe2d9c1bd03e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|