Skip to main content

Official Python client for Scrapely.io API

Project description

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: Contains result (CrawlerResult) with fields like html, text, cookies, screenshot.
  • CaptchaResponse: Contains result (CaptchaResult) with the solution string.

License

MIT

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

scrapely_python_client-0.1.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

scrapely_python_client-0.1.2-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file scrapely_python_client-0.1.2.tar.gz.

File metadata

  • Download URL: scrapely_python_client-0.1.2.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for scrapely_python_client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 10b6fe2e1c1b2af6e4066ca45b3286d0d17c2c08e92c4cbc8474112d8ed297c8
MD5 d05db7721d2a73636ed64857d541a603
BLAKE2b-256 49ef77c8646c38a0cc7df728a4f3f967041f6510dc79a0eeb92ee4f64803403b

See more details on using hashes here.

File details

Details for the file scrapely_python_client-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapely_python_client-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b7f9aca4e2496a83374eba366d323e6a899b429704e262ca89ba36aad80ac718
MD5 d1463a66ddcd1f2b3d968bd2f69f1048
BLAKE2b-256 1be9ce7daf852b13aca7e8bfefbf21d6e05a17c30bc6abb0aaa2444f5ec33881

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