Rendering JavaScript
Rendering JavaScript is disabled by default. This way, scraping goes faster but sometimes you actually do want to wait for JS to render.
To enable JavaScript rendering, just add a render_js=true
query param:
- cURL
- Python
- JavaScript
curl https://scraping.narf.ai/api/v1/?render_js=true&api_key=<your API key>&url=https://example.com
import requests
url = "https://example.com"
api_key = "[your API key]"
print(requests.get(f"https://scraping.narf.ai/api/v1/?render_js=true&api_key={api_key}&url={url}").content)
import axios from "axios";
const url = "https://example.com"
const apiKey = "[your API key]"
const response = await axios.get(`https://scraping.narf.ai/api/v1/?render_js=true&api_key=${apiKey}&url=${url}`);
console.log(response.data);
You do not pay anything extra for requests with JavaScript rendering enabled. We strive to make our pricing clear and the cost of each request is the same regardless of which features of the API you use.
For many URLs, the resulting HTML will look exactly the same with and without JS rendering. However, there are websites which render content dynamically and load relevant data by executing JavaScript code in the browser.
Another reason why you might want to try enabling JS rendering is to bypass anti-bot detection mechanisms which sometimes run JS for browser fingerprint check, etc. In case you happen to consistently experience high rate of 500 errors or timeouts, we encourage you to enable JS rendering.
The request with JS rendering enabled might take slightly more time as it needs to render the JS.