Skip to content

Fetch HTML

The /content endpoint instructs the browser to navigate to a website and capture the fully rendered HTML of a page, including the head section, after JavaScript execution. This is ideal for capturing content from JavaScript-heavy or interactive websites.

Basic usage

Go to https://example.com and return the rendered HTML.

Terminal window
curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <apiToken>' \
-d '{"url": "https://example.com"}'

Advanced usage

Navigate to https://cloudflare.com/ but block images and stylesheets from loading. Undesired requests can be blocked by resource type (rejectResourceTypes) or by using a regex pattern (rejectRequestPattern).

Terminal window
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content' \
-H 'Authorization: Bearer <apiToken>' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://cloudflare.com/",
"rejectResourceTypes": ["image"],
"rejectRequestPattern": ["/^.*\\.(css)"]
}

Parameters

  • url (string) - The URL of the webpage to extract content from.
  • rejectResourceTypes (array) - Blocks specific resource types such as images, fonts from loading to improve performance.
  • rejectRequestPattern (array of regex patterns) - Prevents loading of resources matching specified patterns such as CSS files.