# AI use cases for Moli (lexmount/moli)

Repo: [lexmount/moli](https://github.com/lexmount/moli) | Use cases: 4 | Page: https://dedupedai.com/use-cases/lexmount-moli/

Moli is an open-source headless browser written in Rust that AI agents use to fetch pages, extract content, and automate browser tasks.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Fetch a web page as Markdown for an AI agent: https://dedupedai.com/use-cases/lexmount-moli/fetch-page-as-markdown-for-agent/
- Get a compact semantic tree of a page for a model: https://dedupedai.com/use-cases/lexmount-moli/get-compact-semantic-tree-for-llm/
- Capture a screenshot or PDF of a web page: https://dedupedai.com/use-cases/lexmount-moli/capture-screenshot-or-pdf-of-page/
- Drive Moli from Playwright over CDP: https://dedupedai.com/use-cases/lexmount-moli/drive-moli-from-playwright-over-cdp/

## How to fetch a web page as Markdown for an AI agent with Moli

Repo: [lexmount/moli](https://github.com/lexmount/moli) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Turn any public page into clean Markdown text that an agent can read and reason over.

**Who it is for:** A developer or researcher building an AI agent that must read web pages, triggered when raw HTML is too noisy to feed a model.

**The problem:** Raw HTML is bloated and hard for a language model to use, and many pages need JavaScript to show their content.

**The outcome:** A Markdown rendering of the target page printed to the terminal, with JavaScript-rendered content included.

### Steps

1. Install the Moli binary with `curl --proto '=https' --tlsv1.2 -fsSL https://github.com/lexmount/moli/releases/latest/download/moli-installer.sh | sh` on Linux or macOS, or run the PowerShell installer from the README on Windows. (inferred, check the README)
2. Run `moli fetch --dump markdown --wait-until done https://example.com` to render the page as Markdown. (inferred, check the README)
3. Replace the example URL with your target and redirect output to a file if your agent reads from disk.

### Prompt to paste into your agent

```text
Using the repo lexmount/moli, install the prebuilt Moli binary and run `moli fetch --dump markdown --wait-until done <target-url>`. Output the Markdown of the page. Verify that the main body text of the page appears and is not just a blank shell.
```

### Caveat

Moli's own benchmark counts a page as useful only when meaningful content appears after JavaScript runs, and its mixed crawl success rate was 53.6%, so some pages will still come back thin.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/lexmount-moli/fetch-page-as-markdown-for-agent/

## How to get a compact semantic tree of a page for a model with Moli

Repo: [lexmount/moli](https://github.com/lexmount/moli) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Export a short structured text outline of a page, sized for model context windows.

**Who it is for:** An engineer building a browser-use agent who needs the agent to see page structure instead of pixels or full HTML.

**The problem:** Full DOM dumps overflow the context window, and screenshots cost more to process than the agent needs.

**The outcome:** A compact semantic tree printed as text that lists the page structure the agent can act on.

### Steps

1. Install the Moli binary using the installer from the README.
2. Run `moli fetch --dump semantic_tree_text --wait-selector body https://example.com` to return the semantic tree. (inferred, check the README)
3. Swap in your target URL and, if the page loads content late, change the selector to one that appears only after the content is ready.

### Prompt to paste into your agent

```text
Using the repo lexmount/moli, run `moli fetch --dump semantic_tree_text --wait-selector body <target-url>`. Return the semantic tree text. Verify that headings and links from the page appear in the output.
```

### Caveat

The README describes the semantic tree as model-friendly but does not give a size limit, so check the output length against your model's context window.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/lexmount-moli/get-compact-semantic-tree-for-llm/

## How to capture a screenshot or PDF of a web page with Moli

Repo: [lexmount/moli](https://github.com/lexmount/moli) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Save a PNG or PDF of a rendered page for review, reports, or visual checks.

**Who it is for:** A QA tester or operations person who needs an image or PDF of a live page, triggered by a need for visual evidence.

**The problem:** Text extraction alone cannot show how a page looks, and most headless setups need a separate browser install to take pictures.

**The outcome:** A PNG of the viewport or the full page, or a paginated PDF, saved to a local file.

### Steps

1. Install the Moli binary from the README installer.
2. Run `moli fetch --layout --dump screenshot https://example.com > page.png` for a viewport PNG.
3. Run `moli fetch --layout --dump pdf https://example.com > page.pdf` to save a paginated PDF instead.

### Prompt to paste into your agent

```text
Using the repo lexmount/moli, run `moli fetch --layout --dump screenshot <target-url> > page.png`. Save the PNG and report its file size. Verify that the file opens as an image showing the page.
```

### Caveat

Visual output requires the --layout flag because layout and rendering are off by default, so screenshots will not appear without it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/lexmount-moli/capture-screenshot-or-pdf-of-page/

## How to drive Moli from Playwright over CDP with Moli

Repo: [lexmount/moli](https://github.com/lexmount/moli) | Difficulty: Advanced | Time: 30 minutes | Basis: From the README

Run a local Moli server and control it from an existing Playwright script.

**Who it is for:** A developer with an existing Playwright automation who wants a lighter browser backend, triggered by high memory use from a full Chromium install.

**The problem:** Chromium-based automation uses a lot of memory per session, and moving existing Playwright scripts to another browser usually means rewriting them.

**The outcome:** A Playwright script that loads a page and prints its body text through the Moli server, with no code changes beyond the connection.

### Steps

1. Install the Moli binary from the README installer.
2. Run `moli serve` to start the automation server, which serves CDP, WebDriver Classic, and WebDriver BiDi on one endpoint.
3. Install Playwright in your project with `npm install playwright`. (inferred, check the README)
4. Run the README Playwright script that calls `chromium.connectOverCDP("http://127.0.0.1:9222")`, then `page.goto` and `page.locator("body").innerText()`.

### Prompt to paste into your agent

```text
Using the repo lexmount/moli, start the server with `moli serve` and connect Playwright to http://127.0.0.1:9222 with connectOverCDP. Navigate to <target-url> and print the body innerText. Verify that the printed text matches the visible text of the page.
```

### Caveat

The README says DOM-first mode is the default and that geometry, coordinate input, and screenshots need `moli serve --layout`, so some Playwright calls will fail without that flag.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/lexmount-moli/drive-moli-from-playwright-over-cdp/
