Use the waitFor parameter to delay scraping until a specific HTML element appears on the page.

This is useful when the target content is rendered dynamically with JavaScript — for example, when you need to wait for product details, prices, or reviews to load after initial page render.

How It Works

  • waitFor takes a CSS selector as its value (e.g. .product-title, #main, div[data-loaded=true])
  • Scraping will begin only after the element is detected in the DOM
  • If the element does not appear the request will fail

When to Use

  • The page loads blank or incomplete without JS rendering
  • You need to wait for a modal, tab, or dynamically loaded section to appear
  • You want to avoid capturing partial content due to async loading delays

Example Request

curl --request POST \
  --url 'https://api.hasdata.com/scrape/web' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <your-api-key>' \
  --data '{
    "url": "https://example.com/product/123",
    "waitFor": ".product-details",
    "jsRendering": true,
    "outputFormat": ["html"]
  }'

In this case, scraping will start only after .product-details is present on the page.

Notes

  • This feature requires "jsRendering": true
  • Combine with wait (time delay in ms) for extra control if needed
  • If the selector never appears, you’ll receive a 400 response with an appropriate error