Copy-paste ready Python scripts. Build autonomous agents in minutes.
Each template is production-ready, fully commented, and tested with real SiliconBridge tasks.
Use Playwright to scrape websites. When blocked by CAPTCHA, delegate to human via SiliconBridge.
#!/usr/bin/env python3
"""
Scraping Agent with CAPTCHA Fallback
Uses Playwright to navigate & scrape. When blocked, uses SiliconBridge.
"""
from playwright.async_api import async_playwright
from siliconbridge import SiliconBridge
import asyncio
API_KEY = "sk_YOUR_API_KEY"
TARGET_URL = "https://example.com/pricing"
QUERY = "Extract all pricing tiers and features"
sb = SiliconBridge(api_key=API_KEY)
async def scrape_with_fallback():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
try:
# Try normal navigation
await page.goto(TARGET_URL, timeout=10000)
content = await page.content()
# Check for CAPTCHA
if "recaptcha" in content or "challenge" in content:
print("CAPTCHA detected, delegating to human...")
result = await sb.web_browse(
url=TARGET_URL,
query=QUERY,
include_tables=True
)
print(f"Result: {result.text}")
else:
# Extract content normally
text = await page.locator("body").text_content()
print(f"Scraped {len(text)} chars directly")
except Exception as e:
print(f"Navigation failed: {e}, using web_browse...")
result = await sb.web_browse(url=TARGET_URL, query=QUERY)
print(f"Result: {result.text}")
finally:
await browser.close()
if __name__ == "__main__":
asyncio.run(scrape_with_fallback())
Register accounts automatically. Use SiliconBridge to relay OTP codes when 2FA blocks progress.
#!/usr/bin/env python3
"""
Account Registration Agent with OTP Relay
Automatically registers accounts. Handles 2FA via SiliconBridge.
"""
import httpx
from siliconbridge import SiliconBridge
import json
API_KEY = "sk_YOUR_API_KEY"
PHONE = "+1234567890"
PLATFORM = "example.com"
sb = SiliconBridge(api_key=API_KEY)
client = httpx.AsyncClient()
async def register_account():
# Step 1: Create account
print(f"Registering account on {PLATFORM}...")
resp = await client.post(
f"https://{PLATFORM}/api/register",
json={
"email": "agent@example.com",
"password": "SecurePassword123!",
"phone": PHONE
}
)
print(f"Registration started: {resp.status_code}")
# Step 2: Server sends OTP to phone
print(f"OTP code should be sent to {PHONE}...")
# Step 3: Get OTP via SiliconBridge
print("Requesting OTP relay from SiliconBridge...")
otp_result = await sb.otp.relay(
phone=PHONE,
platform=PLATFORM,
otp_type="sms",
timeout_seconds=120
)
print(f"OTP received: {otp_result.code}")
# Step 4: Verify OTP
verify_resp = await client.post(
f"https://{PLATFORM}/api/verify-otp",
json={
"email": "agent@example.com",
"otp_code": otp_result.code
}
)
print(f"Verification: {verify_resp.status_code}")
if verify_resp.status_code == 200:
print("Account registered successfully!")
return verify_resp.json()
else:
print(f"Verification failed: {verify_resp.text}")
return None
if __name__ == "__main__":
import asyncio
result = asyncio.run(register_account())
print(json.dumps(result, indent=2))
Autonomous research agent that delegates complex web queries to human operators via SiliconBridge.
#!/usr/bin/env python3
"""
Research Agent with Human Web Browsing
Autonomously researches topics by delegating complex queries to humans.
"""
from siliconbridge import SiliconBridge
import json
API_KEY = "sk_YOUR_API_KEY"
sb = SiliconBridge(api_key=API_KEY)
async def research_topic(topic: str, questions: list[str]):
"""
Research a topic by asking humans to browse and answer questions.
"""
findings = {}
for i, question in enumerate(questions, 1):
print(f"\n[{i}/{len(questions)}] {question}")
print("Browsing with human operator...")
# Delegate to human operator
result = await sb.web_browse(
url="https://www.google.com/search",
query=f"{topic} {question}",
include_tables=True,
max_wait_seconds=15
)
findings[question] = {
"answer": result.text[:500], # First 500 chars
"images_found": result.images_found,
"sources": result.links[:3] # First 3 links
}
print(f"Found: {result.images_found} images, {len(result.links)} links")
# Compile research report
report = {
"topic": topic,
"timestamp": datetime.now().isoformat(),
"findings": findings,
"cost_cents": len(questions) * 100 # $1 per web_browse
}
return report
if __name__ == "__main__":
import asyncio
from datetime import datetime
topic = "Quantum Computing"
questions = [
"What are the latest breakthroughs in quantum computing?",
"Which companies are leading quantum development?",
"What are the challenges with current quantum systems?"
]
report = asyncio.run(research_topic(topic, questions))
print("\n" + "="*60)
print("RESEARCH REPORT")
print("="*60)
print(json.dumps(report, indent=2))
Sign up at https://siliconbridge.xyz/api/signup to get your API key + $10 free credits.
pip install siliconbridge playwright
Choose a template above, replace sk_YOUR_API_KEY, and run it.
Use these templates with CrewAI, LangChain, AutoGPT, or any Python LLM framework.