Python SDK
Complete method reference for the Crawlingo Python SDK (PyO3 bindings). Requires Python 3.8+.
12 min read Updated July 2026
ℹ️
Installation
pip install crawlingo — Python 3.8+. Pre-built wheels for Linux (x86_64, aarch64), macOS (Intel, Apple Silicon), Windows AMD64.Session
Central config container. All operations bind to a Session and share its FetchManager, rate limiter, connection pool, middleware stack, and fingerprint store. Use as a context manager for automatic cleanup.
| Method | Returns | Description |
|---|---|---|
Session() / Session.from_config(path) | Session | Create from defaults or TOML/env config |
.headers(dict) | Self | Default HTTP headers for all requests |
.cookies(dict) | Self | Default cookies for all requests |
.proxy(str) | Self | Single proxy URL |
.proxy_pool(list) | Self | Round-robin proxy rotation list |
.proxy_provider(str) | Self | Remote proxy list endpoint URL |
.rate_limit(float) | Self | Per-host req/s (0.0 = unlimited) |
.auto_match(bool) | Self | Enable self-healing selector repair |
.auto_match_weights(*floats) | Self | Fingerprint similarity weights (tag, class, id, attr, text, parent, pos, sibling, depth) |
.timeout(int) | Self | Request timeout in seconds |
.fetcher_tier(str) | Self | "standard" or "stealthy" |
.browser_profile(str) | Self | "chrome", "firefox", or "safari" |
.cache_enabled(bool) | Self | Enable response caching (Cache-Control, ETag aware) |
.retry_base_delay(int) | Self | Initial retry delay (ms) |
.retry_max_delay(int) | Self | Maximum retry delay (ms) |
.retry_multiplier(float) | Self | Exponential backoff factor |
.basic_auth(user, pass) | Self | HTTP Basic Auth |
.bearer_auth(token) | Self | Bearer token auth |
.header_auth(name, value) | Self | Custom auth header |
.api_key_auth(param, value) | Self | Query parameter API key |
.auth_oauth2(client_id, secret, token_url) | Self | OAuth2 with auto-refresh on 401 |
.page(url) | Page | Fetch a page using this session |
.metrics() | dict | Lock-free metrics snapshot |
.clone() | Session | Clone session and its config |
.destroy() | None | Destroy session and release resources |
Page
| Method | Returns | Description |
|---|---|---|
Page(url, session?) | Page | Fetch and parse URL (sync) |
.title() | str | <title> text content |
.html() | str | Raw HTML string |
.markdown() | str | GitHub-flavored markdown |
.status | int | HTTP response status code |
.css(selector) | ElementList | CSS query — returns ElementList |
.xpath(expr) | ElementList | XPath query — returns ElementList |
.regex(pattern) | MatchList | Regex matches against all visible text |
.find_text(text) | ElementList | SIMD text anchor lookup |
.after_text(text) | ElementList | Sibling element after text anchor |
.before_text(text) | ElementList | Sibling element before text anchor |
ElementList & ElementRef
Dataset
| Method | Returns | Description |
|---|---|---|
Dataset(url, session?) | Dataset | Create for a URL |
.field(name, selector, selector_type?, transform?, default?) | Self | Add extraction field |
.with_schema(schema) | Self | Apply DatasetSchema validation |
.build() | DatasetResult | Execute extraction synchronously |
.build_async() | Awaitable[DatasetResult] | Execute extraction asynchronously |
.build_structured() | list[dict] | Extract multi-row table records from a page |
→ .to_dict() | dict | Fields as Python dict |
→ .to_json(path) | None | Write JSON file |
→ .to_csv(path) | None | Write CSV file |
→ .to_parquet(path) | None | Write Apache Parquet file |
→ .df() | DataFrame | Return as Pandas DataFrame |
Extraction Types
| Type | Input → Output | Use Case |
|---|---|---|
text | " Hello " → "Hello" | General text trimming (default) |
price | "$1,234.56" → "1234.56" | Currency normalization |
datetime | "Jan 15, 2024" → "2024-01-15" | Date standardization to ISO 8601 |
url | "/path" → "https://base.com/path" | Relative URL resolution |
datalink_url | <a href="..."> → href value | Link extraction |
datalink_email | "mailto:a@b.com" → "a@b.com" | Email extraction |
datalink_phone | "tel:+1234" → "+1234" | Phone number extraction |
Schema & Pagination Config
New in v1.0.0-beta.1: Configure crawl pagination loops and validate extracted datasets against strict schemas.
PaginationConfig
Exposes factory methods to configure crawl navigation:
crawlingo.PaginationConfig.next_link(selector: str)crawlingo.PaginationConfig.page_number(template: str, start: int, max: int)crawlingo.PaginationConfig.url_pattern(regex: str, max_page: int)- Configure on Crawl:
crawl.with_pagination(config) - Resumable crawls:
Crawl.resumable(url, session, db_path)
DatasetSchema
Validate types and required fields on datasets:
schema = crawlingo.DatasetSchema()schema.add_field(name: str, field_type: FieldType, required: bool)FieldTypeoptions:String,Integer,Float,Boolean- Attach to Dataset:
dataset.with_schema(schema) - Run async:
await dataset.build_async()
Crawl & Watch
See the Quick Start for full Crawl and Watch examples. Key builder methods:
Crawl
.follow(css).limit(n).depth(n).concurrency(n).delay(secs).field(name, sel, selector_type?, default?).with_pagination(config).webhook(url).build() → CrawlResultsCrawlResults.to_json(path)CrawlResults.to_csv(path)CrawlResults.to_parquet(path)
Watch
.field(name, sel, selector_type?, transform?, default?).interval(secs).on_change(fn).on_price_change(fn).on_stock_change(fn).on_element_added(fn).on_element_removed(fn).run() # blocking.run_async() # awaitable.stop()
