Skip to main content

An integration package connecting Spidra and LangChain

Project description

langchain-spidra

PyPI - Version PyPI - License

This package contains the LangChain integration with Spidra, an AI-powered web scraping and crawling API. It lets you scrape, crawl, and batch-scrape the web — as a document loader for RAG pipelines or as agent tools.

Quick Install

pip install langchain-spidra

Get an API key from spidra.io and set it as the SPIDRA_API_KEY environment variable (or pass api_key=...).

export SPIDRA_API_KEY="spd-your-api-key"

Document loader

SpidraLoader loads web content as LangChain Documents. Pick a mode: scrape (one page), crawl (a whole site), or batch (many URLs in parallel).

from langchain_spidra import SpidraLoader

# Scrape a single page
loader = SpidraLoader(url="https://example.com", mode="scrape")
docs = loader.load()
print(docs[0].page_content[:200])
print(docs[0].metadata)

# Crawl an entire docs site
loader = SpidraLoader(url="https://docs.example.com", mode="crawl")
docs = loader.load()

# Batch scrape many URLs
loader = SpidraLoader(
    urls=["https://a.com", "https://b.com", "https://c.com"],
    mode="batch",
)
docs = loader.load()

Tools

Each Spidra capability is also available as a BaseTool you can bind to an agent:

from langchain_spidra import SpidraScrape, SpidraCrawl, SpidraBatchScrape

scrape = SpidraScrape()
result = scrape.invoke({"url": "https://example.com"})
print(result["content"])

crawl = SpidraCrawl()
pages = crawl.invoke({"url": "https://docs.example.com", "max_pages": 20})
for page in pages:
    print(page["url"], page["data"][:100])

batch = SpidraBatchScrape()
items = batch.invoke({"urls": ["https://a.com", "https://b.com"]})

Examples

For complete, runnable implementations showing how to integrate Spidra into your LangChain applications, check out the examples directory:

  • Examples README: Instructions to setup credentials and run each example script.
  • Scrape & Summarize: Scrape a single webpage and generate a summary using a ChatModel.
  • Structured Extraction: Extract formatted, typed data structures from websites using Pydantic schemas.
  • Tool-Calling Agent: Bind Spidra tools to an agent executor, allowing LLMs to search and browse dynamically.
  • Crawl & RAG Pipeline: Crawl site domains, chunk documents, index them, and run retrieval Q&A.

Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_spidra-0.1.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_spidra-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_spidra-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_spidra-0.1.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for langchain_spidra-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8cf4b4cdf76c06c4aeac198bd9c382acd456288e7d3ff6e257a7778c8de150ed
MD5 7bf506679529c924fe70c07d7a2ed7f6
BLAKE2b-256 db5fc2de053201a00f5ac06a9a5fc34f1c4a366da1be0b0cff474f63c6dcad29

See more details on using hashes here.

File details

Details for the file langchain_spidra-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_spidra-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 111523b3cfb95b5f24122e6e77e3c6d11feaeaf0dda1b12534e3d168b0ea9edf
MD5 a8526fea4113924a4a65b473967d3b94
BLAKE2b-256 204884fc45f3ce46b43b62be9a355a9280933586e1136b075f1caa75d4e84a92

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page