crawailer/demo_claude_integration.py
Crawailer Developer cffd04e4ca Add interactive asciinema demos 🎬
- Created demo_basic_usage.py showing Crawailer vs requests
- Created demo_claude_integration.py for MCP server showcase
- Recorded asciinema sessions for both demos
- Added demo viewing instructions to README
- Provides interactive way to see Crawailer in action
- Perfect for developers who want to see before installing
2025-09-18 17:26:13 -06:00

76 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""
Claude Code MCP integration demo for asciinema recording
Shows how easy it is to give Claude web access
"""
import asyncio
from rich.console import Console
from rich.panel import Panel
from rich.syntax import Syntax
console = Console()
async def demo_claude_integration():
"""Demo Claude Code MCP integration"""
console.print("\n🧠 [bold blue]Claude Code MCP Integration Demo[/bold blue]\n")
console.print("[dim]\"Hey Claude, go grab that data from the React app\"[/dim] ← This actually works now!\n")
# Show the MCP server code
mcp_code = '''# Add to your Claude Code MCP server
from crawailer.mcp import create_mcp_server
@mcp_tool("web_extract")
async def extract_content(url: str, script: str = ""):
"""Extract content from any website with optional JavaScript execution"""
content = await web.get(url, script=script)
return {
"title": content.title,
"markdown": content.markdown,
"script_result": content.script_result,
"word_count": content.word_count
}'''
syntax = Syntax(mcp_code, "python", theme="monokai", line_numbers=True)
console.print(Panel(syntax, title="🔧 MCP Server Setup", border_style="blue"))
await asyncio.sleep(3)
# Show Claude conversation
console.print("\n💬 [bold]Claude Code Conversation:[/bold]")
await asyncio.sleep(1)
console.print("\n[cyan]You:[/cyan] Claude, can you extract the pricing info from https://shop.example.com/product/123?")
await asyncio.sleep(2)
console.print("\n[green]Claude:[/green] I'll extract that pricing information for you!")
console.print("[green]Claude:[/green] [dim]Using web_extract tool...[/dim]")
await asyncio.sleep(2)
console.print("\n[green]Claude:[/green] Here's the pricing information I extracted:")
# Show extracted content
result_panel = Panel.fit(
"[green]**Product:** Premium Widget Pro\n"
"**Price:** $299.99 (was $399.99)\n"
"**Discount:** 25% off - Limited time!\n"
"**Stock:** 47 units available\n"
"**Shipping:** Free 2-day delivery\n"
"**Reviews:** 4.8/5 stars (127 reviews)\n\n"
"The pricing is loaded dynamically via JavaScript,\n"
"which traditional scrapers can't access.[/green]",
title="📊 Extracted Data",
border_style="green"
)
console.print(result_panel)
console.print("\n🎉 [bold green]Benefits:[/bold green]")
console.print(" • No more \"I can't access that site\"")
console.print(" • No more copy-pasting content manually")
console.print(" • Your AI can now browse the web like a human")
console.print("\n⚡ [bold]Claude Code + Crawailer = Web superpowers for your AI![/bold]")
if __name__ == "__main__":
asyncio.run(demo_claude_integration())