How to Scrape JavaScript-Rendered Pages
Single-page applications built with React, Vue, or Angular load content dynamically after the initial HTML response. A standard HTTP request returns an empty shell — you need full browser execution to get the actual content.
Step-by-Step Guide
Identify whether a page is JavaScript-rendered
View the page source (Ctrl+U) — if the body is mostly empty or contains only a root div, the content is JavaScript-rendered and requires browser execution.
Enable JavaScript rendering in your request
Add `render_js: true` to your AlterLab API request. This triggers a full headless browser that executes all JavaScript before returning the HTML.
Wait for dynamic content to load
Use the `wait_for` parameter to specify a CSS selector that appears only after the JavaScript has finished loading your target data.
Extract data from the rendered HTML
Parse the fully rendered HTML response with your preferred HTML parser to extract the content that was previously invisible to standard scrapers.
Code Example
import requests
response = requests.post(
"https://alterlab.io/api/v1/scrape",
headers={"X-API-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
json={
"url": "https://example.com/spa-page",
"render_js": True,
"wait_for": ".product-list", # Wait for this selector to appear
},
)
data = response.json()
print(data["html"]) # Fully rendered HTML with dynamic contentReplace YOUR_API_KEY with your key from the . No credit card required.
Try this yourself with AlterLab
Run this tutorial on live websites with AlterLab's API. Free tier includes 5,000 requests — no credit card required.
Frequently Asked Questions
What's the difference between render_js true and false?
Without render_js, AlterLab returns the raw HTTP response — fast but misses JavaScript-rendered content. With render_js, a full browser executes all JavaScript and returns the complete DOM.
How long does JavaScript rendering take?
Browser rendering typically adds 2–5 seconds per request compared to simple HTTP fetching. Use rendering only for pages that actually require it to keep costs low.
Responsible Use
AlterLab is designed for extracting publicly available data. Always review the terms of service for any website you access, respect robots.txt directives, and ensure your use case complies with applicable laws in your jurisdiction.
More tutorials
Browse all how-to guides for web scraping — from beginner extractions to advanced multi-page pipelines.
Your first scrape.
Sixty seconds.
$1 free credit — up to 5,000 scrapes. No credit card.
Just a POST request.
No credit card required · $1 free credit, up to 5,000 scrapes · Balance never expires