Skip to main content

WebCrawlerAPI LangChain Integration

WebcrawlerAPI - is a website to LLM data API. It allows to convert websites and webpages markdown or cleaned content.

Pay as you go (No subscription required).

This package provides LangChain integration for WebCrawlerAPI, allowing you to easily use web crawling capabilities with LangChain document processing pipeline.

Installation

Get your API key first

pip install webcrawlerapi-langchain

Usage

Requires Python 3.10 or newer. api_key and base_url fall back to the WEBCRAWLERAPI_API_KEY and WEBCRAWLERAPI_BASE_URL environment variables when not passed.

Basic Loading

from webcrawlerapi_langchain import WebCrawlerAPILoader

# Initialize the loader
loader = WebCrawlerAPILoader(
    url="https://example.com",
    api_key="your-api-key",
    output_format="markdown",
    items_limit=10
)

# Load documents
documents = loader.load()

# Use documents in your LangChain pipeline
for doc in documents:
    print(doc.page_content[:100])
    print(doc.metadata)

Async Loading

# Async loading
documents = await loader.aload()

Lazy Loading

Yields each page as soon as it finishes crawling:

# Lazy loading
for doc in loader.lazy_load():
    print(doc.page_content[:100])

Async Lazy Loading

# Async lazy loading
async for doc in loader.alazy_load():
    print(doc.page_content[:100])

Error Handling

Crawling and API failures raise WebCrawlerAPILoaderError, which is importable from webcrawlerapi_langchain. Invalid parameters raise ValueError.

from webcrawlerapi_langchain import WebCrawlerAPILoaderError

try:
    documents = loader.load()
except WebCrawlerAPILoaderError as e:
    print(f"Crawl failed: {e}")

Configuration

The loader accepts the following parameters:

  • url: The URL to crawl (keyword arguments follow it)
  • api_key: Your WebCrawlerAPI API key. Defaults to WEBCRAWLERAPI_API_KEY
  • base_url: API base URL. Defaults to WEBCRAWLERAPI_BASE_URL
  • output_format: Content format of each Document: markdown (default), cleaned, or html
  • scrape_type: Deprecated, use output_format instead
  • items_limit: Maximum number of pages to crawl (default 10)
  • whitelist_regexp: Regex pattern for URL whitelist
  • blacklist_regexp: Regex pattern for URL blacklist
  • main_content_only: Extract only the main content of each page (default False)
  • max_depth: Maximum crawl depth. 0 is the seed URL only, 1 is the seed URL plus direct links
  • max_age: Max age in seconds for cached content. 0 always fetches fresh content
  • respect_robots_txt: Whether to respect robots.txt (default False)
  • keep_query_params: Keep URL query params when deduplicating links
  • max_polls: Maximum number of job status checks before giving up (default 100)

Document metadata keys: url, title, status_code, created_at, referred_url, depth, cost, job_id, item_id.

If you need help with integration feel free to contact us.

License

MIT License

Metadata

Release files for webcrawlerapi-langchain 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webcrawlerapi-langchain 0.2.0
File Size Uploaded
webcrawlerapi_langchain-0.2.0.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for webcrawlerapi-langchain 0.2.0
File Interpreter ABI Platform
webcrawlerapi_langchain-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / webcrawlerapi_langchain-0.2.0.tar.gz

Download URL webcrawlerapi_langchain-0.2.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ec704f487da052689ac9cac824b1a006aedfec189f09e02d15925470870f1773
BLAKE2b-256 checksum
How to use checksums
f8de4b7c53e44d228054b87dbc5b095f6ecfb2c6a75ebfbacf8c6753e82248c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / webcrawlerapi_langchain-0.2.0-py3-none-any.whl

Download URL webcrawlerapi_langchain-0.2.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
669ed8f8c9b0b41a0ef9e3c66afe3ef85a239439a4865351f4546355ab9291c3
BLAKE2b-256 checksum
How to use checksums
0bfe62da560a07a41c838c19512926a34af6ccf002257a6f80cb9343ad8957e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page