SDKs
Python SDK
Install and use the official Octivas Python SDK for web extraction, crawling, and search.
The official Python SDK provides a convenient interface for all Octivas API endpoints.
Installation
pip install octivasQuick Start
import octivas
client = octivas.Client("your_api_key")Scrape a Page
Extract content from any webpage:
result = client.extract(
url="https://example.com",
formats=["markdown", "html"]
)
print(result.markdown)
print(result.metadata.title)Crawl a Website
Recursively crawl and collect content:
result = client.crawl(
start_url="https://docs.example.com",
max_pages=50
)
print(f"Crawled {result.pages_crawled} pages")
for page in result.pages:
print(f" {page.url}: {page.metadata.title}")Search the Web
Search and extract content from results:
results = client.search(
query="python web scraping best practices",
limit=10
)
for result in results.results:
print(result.title)
print(result.url)
print(result.markdown[:200])
print("---")Complete Example
import octivas
client = octivas.Client("your_api_key")
# Extract data
result = client.extract(
url="https://example.com",
formats=["markdown"]
)
print(result.markdown)
# Crawl a website
crawl_result = client.crawl(
start_url="https://example.com",
max_pages=100
)
for page in crawl_result.pages:
print(page.url)
# Search the web
search_results = client.search(query="python tutorials")
for result in search_results.results:
print(result.title)Error Handling
import octivas
from octivas.exceptions import AuthenticationError, RateLimitError
client = octivas.Client("your_api_key")
try:
result = client.extract(url="https://example.com")
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Rate limit exceeded, please wait")
except Exception as e:
print(f"An error occurred: {e}")