browser

SPA Scraping

SPA scraping targets Single-Page Applications, where the HTML shell is static but all content is rendered by JavaScript after the initial page load.

A Single-Page Application (SPA) loads a minimal HTML shell on first request and uses a JavaScript framework (React, Vue, Angular, Svelte) to render all subsequent views client-side. Navigating between 'pages' within the SPA does not trigger a full server round-trip; instead, the framework updates the DOM based on client-side routing.

Scraping an SPA with a plain HTTP client retrieves only the empty HTML shell — the data of interest has not yet been rendered. A headless browser is required to wait for JavaScript to execute and the target elements to appear in the DOM. The browser must also handle client-side routing correctly, as the URL path changes via the History API rather than a server redirect.

An efficient alternative is to intercept the API calls the SPA makes to its backend. SPAs almost always fetch data from a JSON API; those API endpoints can often be called directly, bypassing the rendering layer entirely and returning structured data without any HTML parsing.

Examples

// Playwright: wait for SPA content to render
await page.goto("https://spa-example.com/products");
await page.waitForSelector(".product-card"); // wait for JS render
const products = await page.$$eval(".product-card", els =>
  els.map(el => ({ name: el.querySelector("h2").textContent }))
);

Related Terms

Extract SPA Scraping data from any website

AlterLab returns clean, structured data from any public URL — no scraper infrastructure needed. Start free, no credit card required.

View API docs

Your first scrape.
Sixty seconds.

$1 free balance. No credit card. No SDK.Just a POST request.

terminal
curl -X POST https://api.alterlab.io/v1/scrape \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "formats": ["markdown"]}'

No credit card required · Up to 5,000 free scrapes · Balance never expires

    SPA Scraping — Web Scraping Glossary | AlterLab