/scrapeJs
Full headless browser scraping with JavaScript rendering. Executes page scripts and captures the final DOM state exactly as a real user would see it.
POST /scrapeJs
When to Use
Use /scrapeJs for:
- Single Page Applications (React, Vue, Angular, Next.js)
- Sites with infinite scroll or lazy-loaded content
- Cloudflare, PerimeterX, or DataDome protected sites
- Pages requiring login or session handling
- Content loaded dynamically via JavaScript/AJAX
- When you need screenshots of rendered pages
Use /scrape instead for:
- Static HTML pages (faster and cheaper)
- REST APIs returning JSON
- Sites that work without JavaScript
Request Parameters
Required Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | The URL to scrape |
Browser Options
| Parameter | Type | Default | Description |
|---|---|---|---|
timeout | integer | 30 | Page load timeout in seconds (10-40) |
userAgent | string | - | Custom user agent string |
emulateDevice | string | - | Emulate device: iPhone X, iPhone 12, Pixel 5, iPad |
viewport | object | - | Custom viewport: {"width": 1920, "height": 1080} |
Wait Options
| Parameter | Type | Description |
|---|---|---|
waitForSelector | string | CSS selector to wait for before capturing (e.g., .main-content) |
postWaitTime | integer | Additional seconds to wait after page load (1-12) |
Resource Blocking
| Parameter | Type | Default | Description |
|---|---|---|---|
blockAds | boolean | true | Block ad networks, trackers, analytics |
blockImages | boolean | false | Block all images (PNG, JPG, GIF, WebP, SVG) |
blockMedia | boolean | false | Block videos, audio, fonts, stylesheets |
Headers & Cookies
| Parameter | Type | Description |
|---|---|---|
headers | string[] | Custom headers as "Header: Value" strings |
cookies | object[] | Cookies to set before navigation. Each: {"name": "...", "value": "...", "domain": "..."} |
Proxy Options
| Parameter | Type | Default | Description |
|---|---|---|---|
geo | string | default | Proxy geo: default, us, eu, residential, br, de, fr, es, au, ca, 4g-eu |
proxy | string | - | Custom proxy URL (overrides geo) |
stickyIpKey | string | - | Key for sticky IP sessions |
Retry Options
| Parameter | Type | Default | Description |
|---|---|---|---|
retryNum | integer | 1 | Number of retry attempts (0-2) |
textNotExpected | string[] | - | Retry if page contains these strings |
Screenshot & Output
| Parameter | Type | Default | Description |
|---|---|---|---|
screenshot | boolean | true | Take a screenshot of the rendered page |
dumpIframe | string | - | Extract iframe content. Use "all" for all iframes or specific selector |
AJAX Interception
| Parameter | Type | Description |
|---|---|---|
catchAjaxHeadersUrlMask | string | URL pattern to intercept XHR/fetch requests (e.g., "/api/") |
Content Extraction
| Parameter | Type | Description |
|---|---|---|
extractorPreset | string | Built-in extractor: markdown, markdown_content, content |
extractor | string | Custom JavaScript extractor code |
Browser Automation Steps
| Parameter | Type | Description |
|---|---|---|
steps | object[] | Array of automation steps to execute before capturing |
Browser Automation Steps
The steps parameter allows you to automate browser interactions:
| Step Type | Properties | Description |
|---|---|---|
click | selector, waitForNavigation | Click an element |
fill | selector, value | Clear input and type text |
type | selector, value | Type text without clearing |
select | selector, value | Select dropdown option |
wait | value (ms) | Wait for milliseconds |
waitForSelector | selector, timeout | Wait for element to appear |
scroll | selector | Scroll to element |
hover | selector | Hover over element |
press | value (key) | Press keyboard key |
navigate | url | Navigate to URL |
keydown | value (key) | Key down event |
keyup | value (key) | Key up event |
Example Requests
Basic Browser Scrape
request.json
{
"url": "https://books.toscrape.com/"
}Wait for Dynamic Content
request.json
{
"url": "https://quotes.toscrape.com/js/",
"waitForSelector": ".quote",
"timeout": 30
}Mobile Device Emulation
request.json
{
"url": "https://news.ycombinator.com/",
"emulateDevice": "iPhone X"
}Block Resources for Speed
request.json
{
"url": "https://www.bbc.com/news",
"blockAds": true,
"blockImages": true,
"blockMedia": true
}Intercept AJAX Requests
request.json
{
"url": "https://quotes.toscrape.com/scroll",
"catchAjaxHeadersUrlMask": "/api/",
"waitForSelector": ".quote"
}With Session Cookies
request.json
{
"url": "https://httpbin.org/cookies",
"cookies": [
{
"name": "session",
"value": "abc123",
"domain": "httpbin.org",
"path": "/"
}
]
}Login Form Automation
request.json
{
"url": "https://quotes.toscrape.com/login",
"steps": [
{"type": "fill", "selector": "#username", "value": "testuser"},
{"type": "fill", "selector": "#password", "value": "secret123"},
{"type": "click", "selector": "input[type='submit']", "waitForNavigation": true}
],
"waitForSelector": ".header-box"
}Custom Viewport
request.json
{
"url": "https://example.com",
"viewport": {"width": 1920, "height": 1080}
}cURL Example
Terminal
curl -X POST https://scraperex1.p.rapidapi.com/scrapeJs \
-H "Content-Type: application/json" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: scraperex1.p.rapidapi.com" \
-d '{
"url": "https://books.toscrape.com/",
"waitForSelector": ".product_pod",
"screenshot": true
}'Response
response.json
{
"body": "<!DOCTYPE html>...",
"info": {
"js": true,
"attemptsNum": 1,
"statusCode": 200,
"screenshot": "https://cdn.scraperex.com/screenshots/2026-02-08T10-00-00-abc123.png",
"finalUrl": "https://books.toscrape.com/",
"headers": ["content-type: text/html; charset=utf-8"],
"pageCookies": "session=abc123; theme=dark"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
body | string | Fully rendered page HTML |
info.js | boolean | Always true for /scrapeJs |
info.attemptsNum | integer | Number of attempts made |
info.statusCode | integer | HTTP status code |
info.screenshot | string | URL to screenshot image |
info.finalUrl | string | Final URL after redirects |
info.headers | string[] | Response headers |
info.pageCookies | string | Page cookies as string |
info.catchedAjax | object | Intercepted XHR data (if catchAjaxHeadersUrlMask was used) |
bodyIframe | object[] | Iframe contents (if dumpIframe was used) |
extractor | object | Extraction results (if extractor was used) |
Device Emulation Options
iPhone XiPhone 12Pixel 5iPad
Best Practices
- Always use waitForSelector - Ensure dynamic content has loaded
- Set appropriate timeout - Default 30s, increase for slow sites
- Block resources when possible - Faster scraping, lower costs
- Use steps for interactive content - Login forms, pagination, modals
- Check screenshots - Debug issues by viewing the captured screenshot