Using ScrapingAnt for Anti-Detection
Learn how to use ScrapingAnt's web scraping API with built-in browser rendering, proxy rotation, and anti-detection.
ScrapingAnt is a web scraping API that runs a real headless browser for every request. This means JavaScript rendering, proxy rotation, and anti-detection are all handled automatically.
Getting Started
Sign up at scrapingant.com to get your API key. The free plan includes 10,000 API credits per month.
pip install scrapingant-client
Using the Python Client
ScrapingAnt provides an official Python SDK:
from scrapingant_client import ScrapingAntClient
client = ScrapingAntClient(token="YOUR_SCRAPINGANT_TOKEN")
result = client.general_request("https://example.com")
print(f"Status: {result.status_code}")
print(f"Content: {result.content[:500]}")
Using the REST API Directly
You can also use ScrapingAnt with plain requests:
import requests
API_TOKEN = "YOUR_SCRAPINGANT_TOKEN"
response = requests.get(
"https://api.scrapingant.com/v2/general",
params={
"url": "https://example.com",
"x-api-key": API_TOKEN,
},
headers={"x-api-key": API_TOKEN},
timeout=60,
)
print(response.status_code)
print(response.text[:500])
Key Features
JavaScript Rendering
Every ScrapingAnt request runs in a real Chromium browser, so SPAs and dynamic content work out of the box:
from scrapingant_client import ScrapingAntClient
client = ScrapingAntClient(token="YOUR_SCRAPINGANT_TOKEN")
# Wait for specific element to load
result = client.general_request(
"https://spa-website.com",
wait_for_selector=".product-list",
)
print(result.content[:500])
Custom Cookies and Headers
from scrapingant_client import ScrapingAntClient
client = ScrapingAntClient(token="YOUR_SCRAPINGANT_TOKEN")
result = client.general_request(
"https://example.com",
cookies="session_id=abc123; lang=en",
headers={"Accept-Language": "en-US,en;q=0.9"},
)
Proxy Country Selection
from scrapingant_client import ScrapingAntClient
client = ScrapingAntClient(token="YOUR_SCRAPINGANT_TOKEN")
# Route through a US proxy
result = client.general_request(
"https://example.com",
proxy_country="US",
)
Browser Actions
ScrapingAnt can interact with pages before returning the HTML:
from scrapingant_client import ScrapingAntClient
client = ScrapingAntClient(token="YOUR_SCRAPINGANT_TOKEN")
# Click a "Load More" button and wait
result = client.general_request(
"https://example.com/products",
browser_actions=[
{"action": "click", "selector": "#load-more"},
{"action": "wait", "timeout": 2000},
],
)
ScrapingAnt vs ScraperAPI
| Feature | ScrapingAnt | ScraperAPI |
|---|---|---|
| JS rendering | Always on | Optional (render=true) |
| Free credits | 10,000/month | 5,000/month |
| Browser actions | Yes | No |
| Proxy types | Residential | Datacenter + Residential |
| SDKs | Python, JS | REST-based |
Both are solid choices. ScrapingAnt is great when you always need JavaScript rendering. ScraperAPI is more flexible when you often scrape simple pages that do not need a browser.