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 dashboard. No credit card required.
Ready to try it?
Run this tutorial on live websites with AlterLab's API. Start free — no credit card required.
Frequently Asked Questions
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 balance. No credit card. No SDK.
Just a POST request.
No credit card required · Up to 5,000 free scrapes · Balance never expire