Stealth Protocol
Advanced anti-detection and bot protection bypass
About Stealth Protocol
Stealth Protocol provides advanced techniques to make your scraping requests appear as legitimate browser traffic. It bypasses common anti-bot measures including Cloudflare, Datadome, PerimeterX, and other protection systems.
Key Features
Browser Fingerprinting
Realistic browser fingerprints that pass advanced detection systems
Human-like Behavior
Simulates natural mouse movements, scrolling, and interaction patterns
Challenge Solving
Automatically solves CAPTCHAs and JavaScript challenges
Header Management
Automatically sets and rotates realistic browser headers
Basic Usage
Enable Stealth Mode
stealth_basic.py
from scrapehub import ScrapeHubClient
client = ScrapeHubClient(api_key="your_api_key")
# Enable stealth protocol
result = client.scrape(
url="https://protected-site.com",
stealth=True # Enables default stealth settings
)
print(result.data)Custom Stealth Configuration
stealth_custom.py
result = client.scrape(
url="https://protected-site.com",
stealth={
"enabled": True,
"level": "aggressive", # "normal", "aggressive", or "paranoid"
"browser": "chrome", # "chrome", "firefox", "safari", "edge"
"platform": "windows", # "windows", "macos", "linux"
"locale": "en-US",
"timezone": "America/New_York"
}
)
print(result.data)Node.js Example
stealth_example.js
const { ScrapeHubClient } = require('@scrapehub/node');
const client = new ScrapeHubClient({
apiKey: process.env.SCRAPEHUB_API_KEY
});
async function scrapeProtectedSite() {
const result = await client.scrape({
url: 'https://protected-site.com',
stealth: {
enabled: true,
level: 'aggressive',
browser: 'chrome',
platform: 'windows'
}
});
console.log(result.data);
}
scrapeProtectedSite();Stealth Levels
Normal
FastBasic anti-detection measures for most websites
- Realistic browser headers
- WebDriver property hiding
- Basic fingerprint randomization
- Success rate: 80-90%
Aggressive
RecommendedAdvanced techniques for protected sites
- All Normal features plus:
- Advanced fingerprint randomization
- Human-like behavior simulation
- Automatic challenge solving
- Success rate: 90-95%
Paranoid
SlowerMaximum stealth for highly protected sites
- All Aggressive features plus:
- Extended warm-up period
- Multiple verification passes
- Residential proxy rotation
- Success rate: 95-98%
Advanced Features
Custom User Agents
stealth_useragent.py
result = client.scrape(
url="https://example.com",
stealth={
"enabled": True,
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
# Or use predefined profiles
"profile": "chrome_120_windows"
}
)Cookie Management
stealth_cookies.py
result = client.scrape(
url="https://example.com",
stealth={
"enabled": True,
"cookies": {
"session_id": "abc123",
"preference": "dark_mode"
},
"cookie_persistence": True # Maintain cookies across requests
}
)JavaScript Execution
stealth_javascript.py
result = client.scrape(
url="https://example.com",
stealth={
"enabled": True,
"execute_javascript": True,
"wait_for_selector": ".dynamic-content",
"custom_js": """
// Custom JavaScript to execute
window.scrollTo(0, document.body.scrollHeight);
await new Promise(r => setTimeout(r, 2000));
"""
}
)Interaction Simulation
stealth_interactions.py
result = client.scrape(
url="https://example.com",
stealth={
"enabled": True,
"simulate_interactions": True,
"actions": [
{"type": "move_mouse", "duration": 1.5},
{"type": "scroll", "amount": 500, "duration": 2},
{"type": "click", "selector": ".load-more"},
{"type": "wait", "duration": 3}
]
}
)Bypassing Common Protections
Cloudflare
bypass_cloudflare.py
result = client.scrape(
url="https://cloudflare-protected-site.com",
stealth={
"enabled": True,
"level": "aggressive",
"bypass": {
"cloudflare": True,
"wait_for_challenge": True,
"max_wait_time": 30 # seconds
}
}
)
# ScrapeHub automatically solves Cloudflare challenges
print(result.data)reCAPTCHA
bypass_recaptcha.py
result = client.scrape(
url="https://site-with-captcha.com",
stealth={
"enabled": True,
"bypass": {
"recaptcha": True,
"captcha_type": "v2", # or "v3", "invisible"
"auto_solve": True
}
}
)
# CAPTCHA is automatically solved
print(result.data)Rate Limiting Evasion
stealth_ratelimit.py
result = client.scrape(
url="https://rate-limited-site.com",
stealth={
"enabled": True,
"level": "aggressive",
"rate_limiting": {
"random_delays": True,
"min_delay": 2, # seconds
"max_delay": 5,
"exponential_backoff": True
}
}
)Best Practices
Stealth Best Practices
- Start with "normal" level and increase only if needed
- Combine stealth with proxy rotation for best results
- Use realistic browser profiles matching your target audience
- Respect rate limits even with stealth enabled
- Monitor success rates and adjust stealth level accordingly
- Cache results to minimize repeated requests
Monitoring Stealth Effectiveness
stealth_monitoring.py
result = client.scrape(
url="https://protected-site.com",
stealth={"enabled": True, "level": "aggressive"}
)
# Check stealth metrics
print(f"Stealth success: {result.stealth_stats['success']}")
print(f"Challenges solved: {result.stealth_stats['challenges_solved']}")
print(f"Detection risk: {result.stealth_stats['detection_risk']}") # low/medium/high
# Adjust strategy based on results
if result.stealth_stats['detection_risk'] == 'high':
print("Consider increasing stealth level or using proxies")Important Notes
- Stealth features may increase request time and cost
- No stealth method is 100% guaranteed against all protections
- Always comply with website terms of service
- Use stealth responsibly and ethically
- Some sites may still block or rate limit even with stealth