Home / Integrations / LangChain
🦜🔗 LANGCHAIN OFFICIAL CONNECTOR • PYTHON & TS

LangChain Web Scraping &
RAG Knowledge Ingestion

Load dynamic websites and documentation trees directly into LangChain `Document` objects. Cut prompt context costs by up to 95% with noise-free Fit-Markdown before vector embedding.

Get Free API Key → RAG Architecture Guide
$ pip install langchain-community firecrawl-py
rag_pipeline.py
# Complete End-to-End LangChain RAG with Wire-Compatible FlyCrawl
from langchain_core.documents import Document
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import Chroma
from langchain_openai import OpenAIEmbeddings
from firecrawl import FirecrawlApp

# 1. Scrape live web knowledge into token-optimized Fit-Markdown (Zero lock-in)
app = FirecrawlApp(api_key="fly_live_YOUR_API_KEY", api_url="https://api.flycrawl.net/v1")
res = app.scrape_url("https://docs.anthropic.com/en/docs/models", params={"formats": ["markdown"]})

# 2. Package as LangChain Document with rich source metadata
doc = Document(
    page_content=res["markdown"],
    metadata={"source": res.get("metadata", {}).get("sourceURL", "https://docs.anthropic.com")}
)

# 3. Chunk with zero HTML noise
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
chunks = splitter.split_documents([doc])

# 4. Ingest into vector store & query
vectorstore = Chroma.from_documents(chunks, OpenAIEmbeddings())
retriever = vectorstore.as_retriever(search_kwargs={"k": 3})
print(f"Ingested {len(chunks)} high-density semantic chunks via FlyCrawl!")
🔄 END-TO-END RAG DATAFLOW

From Chaotic Web to Pristine Vector Retrieval

🌐
1. Live Web URL
Cloudflare & SPA JS rendered
FlyCrawl
2. FlyCrawl Sub-350ms
Strips 95% token noise to Fit-MD
🦜🔗
3. LangChain Document
RecursiveTextSplitter ready
🗄️
4. Vector DB & RAG
Zero hallucination, high recall
📉

95% Prompt Token Reduction

Instead of passing 30,000 tokens of noisy HTML into your LangChain prompt, Fit-Markdown delivers just 1,000 dense tokens containing tables, headings, and code.

🎯

Zero Hallucination Retrieval

Cookie modals and navigation headers frequently confuse LLM embeddings. Stripping them ensures vector chunks only match genuine factual text.

⚡

Autonomous LangGraph Tools

Wrap FlyCrawl with the `@@tool` decorator to let conversational agents search, scrape, and cite live web references on demand.

LangChain Integration FAQs

How does FlyCrawl integrate with LangChain text splitters? +
FlyCrawl outputs standard markdown headings (#, ##, ###) and clean paragraphs. You can pass the output directly into `MarkdownHeaderTextSplitter` or `RecursiveCharacterTextSplitter` with optimal semantic chunk boundaries.
Can I batch ingest thousands of URLs with LangChain? +
Yes! Use our asynchronous Crawler API endpoint (`POST /api/v1/crawl`) to crawl entire sitemaps and stream the resulting documents progressively into your vector store.

Explore Other Framework Integrations

🦙 LlamaIndex 💻 Cursor IDE MCP 🤖 Dify.ai ⚡ n8n Workflows

Build State-of-the-Art LangChain RAG Pipelines

Register in seconds and claim 100 free credits. Start indexing clean, token-efficient web data into your AI models.

Get Started Free → Scraping API Specs