Skip to content

Commit

Permalink
Merge pull request #53 from moons-14/document-loaders
Browse files Browse the repository at this point in the history
Add a description of the cf puppeteer loader in the document.
  • Loading branch information
inaridiy authored Oct 26, 2024
2 parents 41583c8 + c3f012c commit 3844bbc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-pets-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"site": patch
---

Add description for cf puppeteer loader.
2 changes: 1 addition & 1 deletion site/docs/pages/cookbook/cf-workers.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: HTML to Markdown Conversion with Browser Rendering
authors:
- "[Your Name]"
- "[inaridiy](https://github.com/inaridiy)"
date: 2024-03-15
---

Expand Down
27 changes: 26 additions & 1 deletion site/docs/pages/docs/loaders.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ However, they are not recommended for production use.

## Overview of Loaders

Webforai provides three different loaders:
Webforai provides four different loaders:

- **Fetch Loader**: The simplest option, using JavaScript's built-in Fetch API.
- **Playwright Loader**: Ideal for sites requiring JavaScript execution, like SPAs.
- **Puppeteer Loader**: Another option for handling websites with JavaScript execution.
- **CF Puppeteer Loader**: Option to handle websites running JavaScript on cloudflare workers.

## Fetch Loader

Expand Down Expand Up @@ -101,3 +102,27 @@ import { loadHtml } from "webforai/loaders/puppeteer";
const html = await loadHtml("https://example.com");
```

## CF Puppeteer Loader
The **CF Puppeteer Loader** is the best option for loading HTML from sites that rely on JavaScript execution on [cloudflare workers](https://workers.cloudflare.com/). This loader relies on [puppeteer on cloudflare workers](https://developers.cloudflare.com/browser-rendering/platform/puppeteer/).

### Usage
Before using the CF Puppeteer Loader, you need to prepare a wrangler environment and install @cloudflare/puppeteer. Refer to the [cookbook](/cookbook/cf-workers) for instructions on how to create a project.

:::code-group

```bash [npm]
npm install @cloudflare/puppeteer --save-dev
```

```bash [pnpm]
pnpm install -D @cloudflare/puppeteer
```
:::

And then you can use the Playwright Loader as follows:

```ts
import { loadHtml } from "webforai/loaders/cf-puppeteer";

const html = await loadHtml("https://example.com", browser); // browser is the puppeteer browser instance
```

0 comments on commit 3844bbc

Please sign in to comment.