-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[BRAPI]Markdown endpoint docs #21017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66c320e
Markdown endpoint docs
daisyfaithauma f00dded
New header
daisyfaithauma 701142f
Update src/content/docs/browser-rendering/rest-api/markdown-endpoint.mdx
daisyfaithauma 897d381
Update src/content/docs/browser-rendering/rest-api/markdown-endpoint.mdx
daisyfaithauma f12b812
Merge branch 'production' into markdown-endpoint
daisyfaithauma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/content/docs/browser-rendering/rest-api/markdown-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Extract Markdown from a webpage | ||
| sidebar: | ||
| order: 10 | ||
| --- | ||
|
|
||
| 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. | ||
|
|
||
| ## Basic usage | ||
|
|
||
| ### Using a URL | ||
|
|
||
| This example fetches the Markdown representation of a webpage. | ||
|
|
||
| ```bash | ||
| curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -d '{ | ||
| "url": "https://example.com" | ||
| }' | ||
| ``` | ||
|
|
||
| ### JSON response | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```json title="json response" | ||
| { | ||
| "success": true, | ||
| "result": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)" | ||
| } | ||
| ``` | ||
|
|
||
| ### Use raw HTML | ||
|
|
||
| Instead of fetching the content by specifying the URL, you can provide raw HTML content directly. | ||
|
|
||
| ```bash | ||
| curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -d '{ | ||
| "html": "<div>Hello World</div>" | ||
| }' | ||
| ``` | ||
|
|
||
| ### JSON response | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```json title="json response" | ||
| { | ||
| "success": true, | ||
| "result": "Hello World" | ||
| } | ||
| ``` | ||
|
|
||
| ## Advanced usage | ||
|
|
||
| You can refine the Markdown extraction by using the `rejectRequestPattern` parameter. In this example, requests matching the given regex pattern (such as CSS files) are excluded. | ||
|
|
||
| ```bash | ||
| curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -d '{ | ||
| "url": "https://example.com", | ||
| "rejectRequestPattern": ["/^.*\\.(css)/"] | ||
| }' | ||
| ``` | ||
|
|
||
| ### JSON response | ||
|
|
||
| ```json title="json response" | ||
| { | ||
| "success": true, | ||
| "result": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)" | ||
| } | ||
| ``` | ||
|
|
||
| ## Potential use-cases | ||
|
|
||
| 1. **Content extraction:** Convert a blog post or article into Markdown format for storage or further processing. | ||
| 2. **Static site generation:** Retrieve structured Markdown content for use in static site generators like Jekyll or Hugo. | ||
| 3. **Automated summarization:** Extract key content from web pages while ignoring CSS, scripts, or unnecessary elements. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.