Skip to content

Commit e427e1b

Browse files
kathaylToriLindsay
andauthored
Create setting-custom-user-agent.mdx (cloudflare#25073)
* Create setting-custom-user-agent.mdx * Update content-endpoint.mdx add partial * Update json-endpoint.mdx * Update links-endpoint.mdx * Update markdown-endpoint.mdx * Update pdf-endpoint.mdx * Update scrape-endpoint.mdx * Update screenshot-endpoint.mdx * Update snapshot.mdx * Update src/content/partials/browser-rendering/setting-custom-user-agent.mdx Co-authored-by: ToriLindsay <[email protected]> * Update src/content/partials/browser-rendering/setting-custom-user-agent.mdx Co-authored-by: ToriLindsay <[email protected]> --------- Co-authored-by: ToriLindsay <[email protected]>
1 parent d52b7f4 commit e427e1b

File tree

9 files changed

+56
-8
lines changed

9 files changed

+56
-8
lines changed

src/content/docs/browser-rendering/rest-api/content-endpoint.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 2
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, Render } from "~/components";
99

1010
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.
1111

@@ -58,3 +58,8 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
5858
```
5959

6060
Many more options exist, like setting HTTP headers using `setExtraHTTPHeaders`, setting `cookies`, and using `gotoOptions` to control page load behaviour - check the endpoint [reference](/api/resources/browser_rendering/subresources/content/methods/create/) for all available parameters.
61+
62+
<Render
63+
file="setting-custom-user-agent"
64+
product="browser-rendering"
65+
/>

src/content/docs/browser-rendering/rest-api/json-endpoint.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar:
77
order: 9
88
---
99

10-
import { Tabs, TabItem } from "~/components";
10+
import { Tabs, TabItem, Render } from "~/components";
1111

1212
The `/json` endpoint extracts structured data from a webpage. You can specify the expected output using either a `prompt` or a `response_format` parameter which accepts a JSON schema. The endpoint returns the extracted data in JSON format. By default, this endpoint leverages [Workers AI](/workers-ai/). If you would like to specify your own AI model for the extraction, you can use the `custom_ai` parameter.
1313

@@ -349,3 +349,8 @@ In this example, Browser Rendering first calls Anthropic's Claude Sonnet 4 model
349349
}
350350
]
351351
```
352+
353+
<Render
354+
file="setting-custom-user-agent"
355+
product="browser-rendering"
356+
/>

src/content/docs/browser-rendering/rest-api/links-endpoint.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 10
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, Render } from "~/components";
99

1010
The `/links` endpoint retrieves all links from a webpage. It can be used to extract all links from a page, including those that are hidden.
1111

@@ -212,3 +212,8 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
212212
]
213213
}
214214
```
215+
216+
<Render
217+
file="setting-custom-user-agent"
218+
product="browser-rendering"
219+
/>

src/content/docs/browser-rendering/rest-api/markdown-endpoint.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 10
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, Render } from "~/components";
99

1010
The `/markdown` endpoint retrieves a webpage's content and converts it into Markdown format. You can specify a URL and optional parameters to refine the extraction process.
1111

@@ -93,6 +93,11 @@ curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browse
9393
}
9494
```
9595

96+
<Render
97+
file="setting-custom-user-agent"
98+
product="browser-rendering"
99+
/>
100+
96101
## Potential use-cases
97102

98103
1. **Content extraction:** Convert a blog post or article into Markdown format for storage or further processing.

src/content/docs/browser-rendering/rest-api/pdf-endpoint.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 5
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, Render } from "~/components";
99

1010
The `/pdf` endpoint instructs the browser to generate a PDF of a webpage or custom HTML using Cloudflare's headless browser rendering service.
1111

@@ -137,3 +137,8 @@ curl -X POST https://api.cloudflare.com/client/v4/accounts/<acccountID>/browser-
137137
}' \
138138
--output "cloudflare.pdf"
139139
```
140+
141+
<Render
142+
file="setting-custom-user-agent"
143+
product="browser-rendering"
144+
/>

src/content/docs/browser-rendering/rest-api/scrape-endpoint.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 7
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, Render } from "~/components";
99

1010
The `/scrape` endpoint extracts structured data from specific elements on a webpage, returning details such as element dimensions and inner HTML.
1111

@@ -101,3 +101,10 @@ Many more options exist, like setting HTTP credentials using `authenticate`, set
101101
- `html` _(string)_ - Inner HTML of the element.
102102
- `attributes` _(array of objects)_ - List of extracted attributes such as `href` for links.
103103
- `height`, `width`, `top`, `left` _(number)_ - Position and dimensions of the element.
104+
105+
## Advanced Usage
106+
107+
<Render
108+
file="setting-custom-user-agent"
109+
product="browser-rendering"
110+
/>

src/content/docs/browser-rendering/rest-api/screenshot-endpoint.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 3
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, Render } from "~/components";
99

1010
The `/screenshot` endpoint renders the webpage by processing its HTML and JavaScript, then captures a screenshot of the fully rendered page.
1111

@@ -152,3 +152,8 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
152152
```
153153

154154
Many more options exist, like setting HTTP credentials using `authenticate`, setting `cookies`, and using `gotoOptions` to control page load behaviour - check the endpoint [reference](/api/resources/browser_rendering/subresources/screenshot/methods/create/) for all available parameters.
155+
156+
<Render
157+
file="setting-custom-user-agent"
158+
product="browser-rendering"
159+
/>

src/content/docs/browser-rendering/rest-api/snapshot.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 6
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, Render } from "~/components";
99

1010
The `/snapshot` endpoint captures both the HTML content and a screenshot of the webpage in one request. It returns the HTML as a text string and the screenshot as a Base64-encoded image.
1111

@@ -102,5 +102,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
102102
}
103103
}
104104
```
105+
<Render
106+
file="setting-custom-user-agent"
107+
product="browser-rendering"
108+
/>
105109

106110
Many more options exist, like setting HTTP credentials using `authenticate`, setting `cookies`, and using `gotoOptions` to control page load behaviour - check the endpoint [reference](/api/resources/browser_rendering/subresources/snapshot/) for all available parameters.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Set a custom user agent
2+
3+
You can change the user agent at the page level by passing `userAgent` as a top-level parameter in the JSON body. This is useful if the target website serves different content based on the user agent.
4+
5+
:::note
6+
The `userAgent` parameter does not bypass bot protection. Requests from Browser Rendering will always be identified as a bot.
7+
:::

0 commit comments

Comments
 (0)