JavaScript rendering
What is JavaScript rendering
JavaScript rendering is the process of executing JavaScript on a webpage to generate dynamic content. Dynamic content refers to data or elements that are loaded or updated on the webpage after the initial HTML is delivered. Many modern websites rely on JavaScript to load data and modify their layout in real time.
Not using vs using JavaScript rendering
Not using JavaScript rendering:
- Retrieves only the initial HTML.
- Fast and resource-efficient but misses dynamic content.
Using JavaScript rendering:
- Executes JavaScript to load full content, including dynamic data.
- Slower and resource-intensive but essential for modern dynamic sites.
When to use JavaScript rendering
- Static Websites: No JS rendering needed.
- Dynamic Websites: Use JS rendering to capture complete content.
- Interactive Elements: Necessary for scraping data behind user interactions. For example, browser actions.
How to use JavaScript rendering in your requests
To include rendering to your request, you will need to add the headless
parameter with either html
or png
set as the value.
curl --request 'POST' \
--url 'https://scraper-api.smartproxy.com/v2/scrape' \
--header 'Accept: application/json' \
--header 'Authorization: Basic <token>' \
--header 'Content-Type: application/json' \
--data '
{
"target": "universal",
"url": "https://ip.smartproxy.com/ip",
"headless": "html"
}
'
Scraping API Core subscriptions are not able to use the JavaScript rendering parameter, only Advanced subscriptions are eligible.
Updated 5 days ago