/scrape-js: scraping with JS rendering
/scrape-jsBrowser enginehttps://scrapeninja.apiroad.net/scrape-jsheader X-Apiroad-Keyhttps://scrapeninja.p.rapidapi.com/scrape-jsheader X-RapidAPI-Key/scrape-js is the original browser endpoint. It keeps its request and response format for existing integrations, and since November 2026 it runs on the same browser engine as /v2/scrape-js. New integrations should use /v2/scrape-js.
It supports a few legacy options that v2 does not have, such as dumping the content of an iframe.
Quick start
Section titled “Quick start”curl https://scrapeninja.apiroad.net/scrape-js \ -H "Content-Type: application/json" \ -H "X-Apiroad-Key: YOUR_KEY" \ -d '{ "url": "https://example.com/product", "geo": "us", "waitForSelector": ".price", "postWaitTime": 2 }'import requests
res = requests.post( "https://scrapeninja.apiroad.net/scrape-js", headers={"X-Apiroad-Key": "YOUR_KEY"}, json={ "url": "https://example.com/product", "geo": "us", "waitForSelector": ".price", "postWaitTime": 2, }, timeout=120,)data = res.json()print(data["info"]["statusCode"], data["info"].get("screenshot"))const res = await fetch('https://scrapeninja.apiroad.net/scrape-js', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Apiroad-Key': 'YOUR_KEY' }, body: JSON.stringify({ url: 'https://example.com/product', geo: 'us', waitForSelector: '.price', postWaitTime: 2, }),});const data = await res.json();console.log(data.info.statusCode, data.info.screenshot);Parameters
Section titled “Parameters”Request
Section titled “Request”URL to scrape
Custom headers to send with the request. By default, regular Chrome browser headers are sent to the target URL.
Browser
Section titled “Browser”Browser actions to run after the page has loaded (after waitForSelector and postWaitTime): click, type or select, wait for an element. The format is a subset of Chrome DevTools Recorder steps. See Browser steps.
[
{
"type": "change",
"selector": "input[name=q]",
"value": "laptop"
},
{
"type": "click",
"selector": "button[type=submit]",
"waitForNavigation": true
},
{
"type": "waitForElement",
"selector": ".results"
}
]steps[].typeenumWhat to do.steps[].selectorstringCSS selector of the element (or selectors).steps[].selectorsstring[]Alternative selectors, the first visible match wins. Recorder-style nested arrays are accepted.steps[].valuestringFor change: the text to type or the option value to select.steps[].waitForNavigationbooleanWait for the page navigation caused by this step.steps[].waitForXhrRequeststringURL mask of an XHR this step triggers; the response is returned in info.log.CSS selector to wait to appear in DOM tree before page is considered as loaded.
Wait for specified amount of seconds after page load (from 1 to 12s). Use this only if ScrapeNinja failed to wait for required page elements automatically.
Block images from loading. This will speed up page loading and reduce bandwidth usage.
Block (CSS, fonts) from loading. This will speed up page loading and reduce bandwidth usage.
Take a screenshot of the page. Pass "false" to increase the speed of the request.
Advanced. Set custom viewport size. By default, viewport size is 1920x1080.
viewport.widthintegerviewport.heightintegerviewport.deviceScaleFactorintegerviewport.hasTouchbooleanviewport.isMobilebooleanviewport.isLandscapebooleanUseful to dump some XHR response. Pass URL mask here. For example, if you need to catch all requests to https://example.com/api/data.json, pass "api/data.json" here. In response, you will get new property .info.catchedAjax with the XHR response data - { url, method, headers[], body , status, responseHeaders{} }
If some particular iframe needs to be dumped, specify its name HTML value in this argument. The ScrapeNinja JS renderer will wait for <iframe name="icims_content_iframe"> to appear in DOM, then use waitForSelectorIframe CSS selector to wait for iframe DOM elements to appear inside.
If dumpIframe is activated, this property allows to wait for CSS selector inside this iframe.
If dumpIframe is activated, this property allows to run JS extractor function against iframe HTML instead of running it against base body. This is only useful if dumpIframe is activated.
Proxies and retries
Section titled “Proxies and retries”Geo location for basic proxy pools (you can purchase premium ScrapeNinja proxies for wider country selection and higher proxy quality). Read more about ScrapeNinja proxy setup
Premium or your own proxy URL (overrides geo field). Read more about ScrapeNinja proxy setup
Number of retries after the first attempt. Total attempts = retryNum + 1 (retryNum=0 disables retries). A retry is made on proxy/network errors, timeouts and when textNotExpected matches; each retry uses another proxy from the pool.
Timeout per attempt, in seconds. Each retry will take [timeout] number of seconds.
Text which will trigger a retry from another proxy address.
HTTP response statuses which will trigger a retry from another proxy address.
Output and extraction
Section titled “Output and extraction”Custom JS function to extract JSON values from scraped HTML: function (input, cheerio) { ... } (cheerio 1.2, synchronous, 1 s CPU, no network). Write and test it in the Cheerio playground; for big pages see the fast parser option in JS extractors.
function(input, cheerio) {
let $ = cheerio.load(input);
return $('h1.title').text(); } Built-in extractor, used when extractor is empty. markdown: the whole page as Markdown. markdown_content: only the main content (article text without menus and footers) as Markdown, plus meta (title, byline, site name, excerpt). content: the main content as cleaned HTML. The result is returned in extractor.result.
Return the page HTML in body. Set to false when you only need the extractor result: the response gets much smaller.
Return the response headers of the target website in info.headers.
Response
Section titled “Response”info.screenshot holds a URL of the screenshot when screenshot is on.
Request metadata.
HTTP status of the target website (not of ScrapeNinja).
URL after redirects.
XHR response caught by catchAjaxHeadersUrlMask.
—
—
Array of request headers
—
If dumpIframe is activated, this property contains iframe HTML.
—
Object with response headers
Response headers of the target website, as name: value strings.
URL of the page screenshot (when screenshot is on), or null.
Records produced by steps: XHRs caught by waitForXhrRequest, as { type: "xhr", stepIdx, data: { url, method, status, body } }.
HTML body of the rendered page.
Present when extractor or extractorPreset is set.
What your extractor returned (any JSON value). For presets: { markdown, meta } or { html, meta }.
Extractor run time, ms.
Extractor error message, if it failed.
Stack trace of the error inside your extractor.
Line of your extractor where the error happened (/scrape only).