Scrapix
Project description
Scrapix Python SDK
🕷️ A powerful Python SDK for web scraping, crawling, and data extraction
Installation • Quick Start • API Reference • Examples • Documentation
Overview
Scrapix is a Python SDK that provides a simple, powerful interface for web scraping and data extraction. Built on top of the Scrapix API, it offers:
- 🌐 Web Scraping - Extract content from any webpage in multiple formats
- 🔗 URL Collection - Discover and collect URLs from websites and sitemaps
- 🕸️ Web Crawling - Crawl websites to extract URLs with advanced filtering
- 🧠 AI-Powered Extraction - Extract structured data using AI with custom schemas
- ⚡ Built-in Resilience - Automatic retries, timeouts, and error handling
- 🔒 Premium Features - Captcha solving, premium proxies, and JavaScript rendering
Requirements
- Python 3.9+
Installation
Install the package via pip:
pip install scrapix
Or with Poetry:
poetry add scrapix
Quick Start
1. Configure the Client
import os
import scrapix
# Configure the SDK with your API key
configuration = scrapix.Configuration(
host="https://api-scrapix.promptcloud.com", # Your Scrapix API host
api_key={"APIKeyHeader": os.environ.get("SCRAPIX_API_KEY")}
)
2. Scrape a Webpage
with scrapix.ApiClient(configuration) as api_client:
api = scrapix.APIServicesApi(api_client)
# Scrape a webpage
result = api.scrape(scrapix.ScrapeInput(
url="https://example.com",
output_format=scrapix.OutputFormat.MARKDOWN
))
print(result.data)
API Reference
The SDK provides access to the following API endpoints:
| Method | Endpoint | Description |
|---|---|---|
scrape() |
POST /v1/scrape |
Scrape content from a single URL |
crawl() |
POST /v1/crawl |
Crawl a website and collect URLs |
collect() |
POST /v1/collect |
Collect URLs from a page |
extract() |
POST /v1/extract |
Extract structured data using AI |
echo() |
POST /v1/echo |
Test API connectivity |
Authentication
All API requests require an API key. Set it using the APIKeyHeader:
configuration = scrapix.Configuration(
host="https://scrapix.promptcloud.com",
api_key={"APIKeyHeader": "your-api-key-here"}
)
Examples
Scraping Content
Scrape a webpage and get the content in different formats:
import scrapix
configuration = scrapix.Configuration(
host="https://scrapix.promptcloud.com",
api_key={"APIKeyHeader": "your-api-key"}
)
with scrapix.ApiClient(configuration) as api_client:
api = scrapix.APIServicesApi(api_client)
# Scrape with JavaScript rendering enabled
result = api.scrape(scrapix.ScrapeInput(
url="https://example.com",
render=True, # Enable JavaScript rendering
output_format=scrapix.OutputFormat.MARKDOWN,
timeout=60,
max_retries=3
))
print(f"Content: {result.data}")
Crawling a Website
Discover URLs on a website:
import scrapix
with scrapix.ApiClient(configuration) as api_client:
api = scrapix.APIServicesApi(api_client)
# Crawl a website for URLs
result = api.crawl(scrapix.CrawlInput(
url="https://example.com",
urls_limit=50, # Maximum URLs to collect
include_sitemap_urls=True, # Include URLs from sitemap
include_paths="/blog/*", # Only include blog pages
exclude_paths="/admin/*" # Exclude admin pages
))
for url in result.urls:
print(url)
Collecting URLs
Collect all URLs from a specific page:
import scrapix
with scrapix.ApiClient(configuration) as api_client:
api = scrapix.APIServicesApi(api_client)
# Collect URLs from a page
result = api.collect(scrapix.CollectInput(
url="https://example.com/sitemap",
urls_limit=1000,
include_sitemap_urls=True
))
print(f"Found {len(result.urls)} URLs")
AI-Powered Data Extraction
Extract structured data using AI:
import scrapix
with scrapix.ApiClient(configuration) as api_client:
api = scrapix.APIServicesApi(api_client)
# Extract structured data with a query
result = api.extract(scrapix.ExtractInput(
url="https://example.com/products",
query="Extract all product names, prices, and descriptions",
output_format=scrapix.StructuredOutputFormat.JSON
))
print(result.data)
Using Premium Features
Enable advanced features like proxies and captcha solving:
import scrapix
with scrapix.ApiClient(configuration) as api_client:
api = scrapix.APIServicesApi(api_client)
result = api.scrape(scrapix.ScrapeInput(
url="https://protected-site.com",
render=True, # JavaScript rendering
premium_proxies=True, # Use premium residential proxies
use_captcha_solver=True, # Automatically solve CAPTCHAs
use_cache=False # Always fetch fresh content
))
Error Handling
Handle API errors gracefully:
import scrapix
from scrapix.rest import ApiException
with scrapix.ApiClient(configuration) as api_client:
api = scrapix.APIServicesApi(api_client)
try:
result = api.scrape(scrapix.ScrapeInput(url="https://example.com"))
print(result.data)
except ApiException as e:
print(f"API Error: {e.status} - {e.reason}")
print(f"Response body: {e.body}")
except Exception as e:
print(f"Unexpected error: {e}")
Models
Input Models
| Model | Description |
|---|---|
ScrapeInput |
Input for scraping a single URL |
CrawlInput |
Input for crawling a website |
CollectInput |
Input for collecting URLs |
ExtractInput |
Input for AI-powered extraction |
Result Models
| Model | Description |
|---|---|
ScrapeResult |
Result from scrape operation |
CrawlResult |
Result from crawl operation |
CollectResult |
Result from collect operation |
ExtractResult |
Result from extract operation |
Other Models
| Model | Description |
|---|---|
OutputFormat |
Output format options (MARKDOWN, HTML, etc.) |
StructuredOutputFormat |
Structured output formats |
StructuredOutputSchema |
Schema for structured outputs |
SummarizeSchema |
Schema for summarization |
Common Parameters
All input models share these common parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
url |
str |
required | The URL to scrape/crawl |
timeout |
int |
40 | Request timeout in seconds |
max_retries |
int |
5 | Maximum retry attempts |
render |
bool |
False | Enable JavaScript rendering |
premium_proxies |
bool |
False | Use premium residential proxies |
use_captcha_solver |
bool |
False | Enable automatic CAPTCHA solving |
use_cache |
bool |
True | Use cached responses when available |
Documentation
For detailed API documentation, see the docs directory:
- APIServicesApi - Main API endpoints
- DefaultApi - Default API endpoints
Development
Running Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
Type Checking
mypy scrapix
Support
- 📧 Email: sales@promptcloud.com
- 🌐 Website: https://scrapix.promptcloud.com
License
This SDK is provided by PromptCloud. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scrapix-0.1.2.tar.gz.
File metadata
- Download URL: scrapix-0.1.2.tar.gz
- Upload date:
- Size: 38.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"11","id":"bullseye","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8d1a276167e1033f9be6685c63ef3ab769d1098efb8a22f97aa5f2dd2fd4d3f
|
|
| MD5 |
a508615bfb3a8ad44d3aa0d5f5d72eb5
|
|
| BLAKE2b-256 |
a91800681c585ff2a2d52f9affb69e90898d73cc059efacf043d958c10bab534
|
File details
Details for the file scrapix-0.1.2-py3-none-any.whl.
File metadata
- Download URL: scrapix-0.1.2-py3-none-any.whl
- Upload date:
- Size: 55.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"11","id":"bullseye","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c89b2c4f0082622b7d00eb272f4c75050b51d0718f9d3f1c436dc9f933d4898
|
|
| MD5 |
d811334288c633bfa4f2e12b8c0050d0
|
|
| BLAKE2b-256 |
013c97b9a8ef47a4fb0353afc87a0422242ea3df41b73dce44e0e4f1ccdf88b0
|