Przejdź do głównej zawartości

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 render_js=true query parameter:

import requests

payload = {
"api_key": "[your API key]",
"url": "https://example.com",
"render_js": "true",
}

response = requests.get("https://scraping.narf.ai/api/v1/", params=payload)
print(response.content)
tip

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.

note

The request with JS rendering enabled might take slightly more time as it needs to render the JS.