Prompt

How do I scrape a dynamic website that loads content with JavaScript?

Technology / Testing & QA1 observationLast seen Oct 26, 2026

Latest observation

Oct 26, 2026OpenAI APIWeb search: off

To scrape a website that loads content with JavaScript, you usually need a tool that can render the page like a browser, not just download the raw HTML.

Common approaches

1. Use a headless browser

Tools like:

  • Playwright (recommended)
  • Selenium
  • Puppeteer

These open the page, run JavaScript, and let you extract the rendered content.

Example with Playwright (Python)

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    page = browser.new_page()
    page.goto("https://example.com", wait_until="networkidle")
    html = page.content()
    print(html)
    browser.close()

Then you can use BeautifulSoup or similar to parse html.


2. Inspect network requests

Often the page itself is just a shell, and JavaScript fetches data from an API.

Open DevTools in your browser:

  • Go to the Network tab
  • Reload the page
  • Look for:
    • fetch / XHR requests
    • JSON responses
    • API endpoints

If you can find the API directly, scraping becomes much easier and faster than browser automation.

Example idea

Instead of scraping rendered HTML:

import requests

r = requests.get("https://example.com/api/items")
data = r.json()
print(data)

3. Wait for dynamic content

Sometimes content appears after a delay. You may need to wait for a selector.

Playwright example

page.goto("https://example.com")
page.wait_for_selector(".item")
items = page.locator(".item").all_text_contents()
print(items)

4. Scroll or click if needed

For infinite scroll or “Load more” buttons:

  • Scroll the page to trigger loading
  • Click buttons repeatedly
  • Wait for new content each time

Important considerations

  • Check the site’s robots.txt and terms of service
  • Avoid aggressive scraping
  • Add delays and rate limiting
  • Use headers / sessions if needed
  • Be mindful of logins, CAPTCHAs, and anti-bot protection

Best practice

  1. First inspect whether the data comes from an API.
  2. If not, use Playwright/Selenium.
  3. Parse the rendered DOM.
  4. Add waits and scrolling as needed.

If you want, I can show you:

  • a Python Playwright scraper template
  • how to find the API behind a JS site
  • or how to handle infinite scroll / pagination.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.