/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

ParameterTypeDescription
urlstringThe URL to scrape

Browser Options

ParameterTypeDefaultDescription
timeoutinteger30Page load timeout in seconds (10-40)
userAgentstring-Custom user agent string
emulateDevicestring-Emulate device: iPhone X, iPhone 12, Pixel 5, iPad
viewportobject-Custom viewport: {"width": 1920, "height": 1080}

Wait Options

ParameterTypeDescription
waitForSelectorstringCSS selector to wait for before capturing (e.g., .main-content)
postWaitTimeintegerAdditional seconds to wait after page load (1-12)

Resource Blocking

ParameterTypeDefaultDescription
blockAdsbooleantrueBlock ad networks, trackers, analytics
blockImagesbooleanfalseBlock all images (PNG, JPG, GIF, WebP, SVG)
blockMediabooleanfalseBlock videos, audio, fonts, stylesheets

Headers & Cookies

ParameterTypeDescription
headersstring[]Custom headers as "Header: Value" strings
cookiesobject[]Cookies to set before navigation. Each: {"name": "...", "value": "...", "domain": "..."}

Proxy Options

ParameterTypeDefaultDescription
geostringdefaultProxy geo: default, us, eu, residential, br, de, fr, es, au, ca, 4g-eu
proxystring-Custom proxy URL (overrides geo)
stickyIpKeystring-Key for sticky IP sessions

Retry Options

ParameterTypeDefaultDescription
retryNuminteger1Number of retry attempts (0-2)
textNotExpectedstring[]-Retry if page contains these strings

Screenshot & Output

ParameterTypeDefaultDescription
screenshotbooleantrueTake a screenshot of the rendered page
dumpIframestring-Extract iframe content. Use "all" for all iframes or specific selector

AJAX Interception

ParameterTypeDescription
catchAjaxHeadersUrlMaskstringURL pattern to intercept XHR/fetch requests (e.g., "/api/")

Content Extraction

ParameterTypeDescription
extractorPresetstringBuilt-in extractor: markdown, markdown_content, content
extractorstringCustom JavaScript extractor code

Browser Automation Steps

ParameterTypeDescription
stepsobject[]Array of automation steps to execute before capturing

Browser Automation Steps

The steps parameter allows you to automate browser interactions:

Step TypePropertiesDescription
clickselector, waitForNavigationClick an element
fillselector, valueClear input and type text
typeselector, valueType text without clearing
selectselector, valueSelect dropdown option
waitvalue (ms)Wait for milliseconds
waitForSelectorselector, timeoutWait for element to appear
scrollselectorScroll to element
hoverselectorHover over element
pressvalue (key)Press keyboard key
navigateurlNavigate to URL
keydownvalue (key)Key down event
keyupvalue (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

FieldTypeDescription
bodystringFully rendered page HTML
info.jsbooleanAlways true for /scrapeJs
info.attemptsNumintegerNumber of attempts made
info.statusCodeintegerHTTP status code
info.screenshotstringURL to screenshot image
info.finalUrlstringFinal URL after redirects
info.headersstring[]Response headers
info.pageCookiesstringPage cookies as string
info.catchedAjaxobjectIntercepted XHR data (if catchAjaxHeadersUrlMask was used)
bodyIframeobject[]Iframe contents (if dumpIframe was used)
extractorobjectExtraction results (if extractor was used)

Device Emulation Options

  • iPhone X
  • iPhone 12
  • Pixel 5
  • iPad

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