Skip to main content

LangChain x402 CleanWeb Integration

Official LangChain tool integration for x402 CleanWeb Studio (x402-cleanweb-agent).

Enables autonomous LangChain agents, conversational bots, and RAG pipelines to scrape and ingest web content at scale without drowning LLM context windows in boilerplate HTML, navigation scripts, tracking pixels, and ads.


⚡ Key Features

  • 87% Token Compression: Strips boilerplate, ads, cookie modals, and navigation markup before index embedding.
  • Indirect Prompt Injection Defense: Neutralizes hidden CSS text, zero-width steganography, and malicious query-parameter exfiltration links.
  • Multimodal Alt-Text Preservation: Extracts descriptive image alt tags (![alt](url)) for visual LLMs while neutralizing 1x1 tracking pixels.
  • SPA Hydration Extraction: Zero-overhead pre-rendered state parsing for Next.js (__NEXT_DATA__), Nuxt.js (__NUXT_DATA__), and Schema.org JSON-LD.
  • x402 Autonomous Micropayments: Native machine-to-machine USDC micropayments over Base, Polygon, Arbitrum, and Solana with a zero-auth 5-call trial tier.
  • LangChain Standard Compliance: Implements both sync _run and async _arun via langchain_core.tools.BaseTool with Pydantic v2 args_schema.

📦 Installation

pip install langchain-x402-cleanweb

🚀 Quickstart

1. Direct Tool Invocation

from langchain_x402_cleanweb import X402CleanWebTool

# Initialize tool (uses official Cloud Run gateway by default)
tool = X402CleanWebTool()

# Scrape and clean web page
clean_markdown = tool.run("https://en.wikipedia.org/wiki/Web_scraping")
print(clean_markdown)

2. Autonomous LangChain Agent Integration

from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI
from langchain_x402_cleanweb import X402CleanWebTool

llm = ChatOpenAI(model="gpt-4o", temperature=0)
tools = [X402CleanWebTool()]

agent = initialize_agent(
    tools=tools,
    llm=llm,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True
)

response = agent.run("Summarize the latest engineering news on https://news.ycombinator.com")
print(response)

3. Asynchronous Execution

import asyncio
from langchain_x402_cleanweb import X402CleanWebTool

async def main():
    tool = X402CleanWebTool()
    content = await tool.arun("https://docs.python.org/3/whatsnew/3.13.html")
    print(content[:500])

asyncio.run(main())

⚙️ Configuration & Authentication

The tool works out of the box with 5 free trial requests per session nonce.

For production high-throughput autonomous agents, set the environment variable:

export AGENT_VAULT_KEY="your_funded_vault_session_key"

Or pass it programmatically:

tool = X402CleanWebTool(
    vault_key="your_vault_key",
    gateway_url="https://x402-cleanweb-agent-7qxtp3324q-du.a.run.app"
)

🛡️ License

MIT License. Developed by the x402 Autonomous Agent Ecosystem.

Metadata

Release files for langchain-x402-cleanweb 0.1.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 langchain-x402-cleanweb 0.1.0
File Size Uploaded Provenance Actions
langchain_x402_cleanweb-0.1.0.tar.gz 6.6 kB Without provenance Details for langchain_x402_cleanweb-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-x402-cleanweb 0.1.0
File Interpreter ABI Platform Actions
langchain_x402_cleanweb-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_x402_cleanweb-0.1.0-py3-none-any.whl

Total release size: 12.7 kB

Release files / langchain_x402_cleanweb-0.1.0.tar.gz

Download URL langchain_x402_cleanweb-0.1.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7c798fa7f21d72d37d50c582ab17f7bda411389d52e789c368e33f06e6711ed4
BLAKE2b-256 checksum
How to use checksums
5025aa2b7f53b6cbeec3a76d83fdf6901f9acc40938aeea5b07830f56bd7e1b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / langchain_x402_cleanweb-0.1.0-py3-none-any.whl

Download URL langchain_x402_cleanweb-0.1.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1de4bb8f541ae9a8bb2c62c9fa40827e3ec52adb43c9e8b084cd50bd9ba8ae7
BLAKE2b-256 checksum
How to use checksums
0af70faa6a1e9a2c1fb1766da5a2d1bd84e0aba6af1fd58c2f949d3fe06b4348
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for langchain-x402-cleanweb 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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