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 toWEBCRAWLERAPI_API_KEYbase_url: API base URL. Defaults toWEBCRAWLERAPI_BASE_URLoutput_format: Content format of each Document:markdown(default),cleaned, orhtmlscrape_type: Deprecated, useoutput_formatinsteaditems_limit: Maximum number of pages to crawl (default10)whitelist_regexp: Regex pattern for URL whitelistblacklist_regexp: Regex pattern for URL blacklistmain_content_only: Extract only the main content of each page (defaultFalse)max_depth: Maximum crawl depth.0is the seed URL only,1is the seed URL plus direct linksmax_age: Max age in seconds for cached content.0always fetches fresh contentrespect_robots_txt: Whether to respect robots.txt (defaultFalse)keep_query_params: Keep URL query params when deduplicating linksmax_polls: Maximum number of job status checks before giving up (default100)
Document metadata keys: url, title, status_code, created_at, referred_url, depth, cost, job_id, item_id.
Links
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)
| File | Size | Uploaded | |
|---|---|---|---|
| webcrawlerapi_langchain-0.2.0.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|