# Web Page to Markdown for AI (Search + Fetch, RAG Browser) (`locaihost/web-fetch`) Actor

Search Google or paste links and get each page's main content as clean Markdown or text, with tables kept, metadata, RAG chunks and PDF/Word files converted. Blocked or missing pages come back free. $1.50 per 1,000 pages.

- **URL**: https://apify.com/locaihost/web-fetch.md
- **Developed by:** [locaihost data](https://apify.com/locaihost) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.83 / 1,000 page returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Web Page to Markdown for AI (Search + Fetch, RAG Browser)

Search Google or paste links, and get each page's main content back as clean Markdown or plain text: menus, footers, cookie banners and ads removed, tables kept as Markdown tables, code blocks kept. Each row also carries the title, description, publish and update dates, site name, language and canonical link. PDF and Word files are converted too. Feed the rows straight to your AI agent, chatbot or RAG pipeline.

### How do I start?

Paste this into the input (JSON tab) and press Start:

```json
{
    "query": "apify actor pricing pay per event",
    "maxResults": 3
}
```

The run searches Google, opens the top 3 results and returns one row per page, plus one free summary row. It takes about 20 seconds.

To read pages you already know, use `urls` instead (or as well):

```json
{
    "urls": ["https://docs.apify.com/platform/actors", "https://example.com/annual-report.pdf"]
}
```

### What does each row contain?

| Field | What it is |
|---|---|
| `url`, `finalUrl` | The page as requested, and where it ended up after redirects |
| `status` | `ok`, `blocked`, `robots-denied`, `not-found`, `timeout`, `not-html`, `empty` or `error` |
| `message` | Why a page has no content, for every status but `ok` |
| `httpStatus`, `readVia` | The site's HTTP status, and whether the page was read with a plain download (`http`) or a browser (`browser`) |
| `title`, `description`, `siteName`, `language` | From the page's own tags and structured data |
| `publishedAt`, `modifiedAt` | Dates the page states, as ISO 8601 |
| `canonicalUrl` | The canonical link the page declares |
| `markdown`, `text`, `html` | The main content, in the format you picked |
| `wordCount`, `truncated` | Words in the main content, and whether it was cut at your character limit |
| `chunks` | With **RAG chunk size** set: chunks with `text`, `tokensApprox`, `headingPath` and PDF `page` |
| `links` | With **Include links** on: every link on the page |
| `contentHash`, `changed` | A hash of the content, and (with **Only pages that changed**) whether the page is new or changed |
| `searchResult` | For pages found by search: the `query`, Google `position`, `title` and `snippet` |
| `fetchedAt` | When the page was read |

### Free rows, never charged

Only pages returned with content, and the Google searches you ask for, are charged. Pages that are blocked, disallowed by robots.txt, missing, timed out, not a web page or document, or empty come back as rows with their status and a reason, free. So you always see what happened to every link.

Every run also ends with one free summary row (`type: "summary"`): searches run and any that failed, pages read, pages per status, pages skipped as unchanged and pages not read. The **Summary** view shows it on its own.

### What makes it different?

- **Search and read in one call.** One query in, the top pages' content out, ready for a prompt. Or skip the search and paste links.
- **Clean main content.** The article or documentation body only, with headings, lists, links, code blocks and tables kept in Markdown.
- **PDF and Word files too.** A link to a PDF or .docx file is converted to Markdown with its tables and headings, page markers kept in the chunks.
- **RAG chunks with heading paths.** Set a chunk size and every page is split at headings and paragraphs, each chunk tagged with the headings above it.
- **Only changed pages.** Schedule a daily run on the same links and turn on **Only pages that changed**: unchanged pages are skipped and free.
- **Browser only when needed.** Every page is read with a fast plain download first; a browser opens only for pages drawn by scripts.
- **Polite.** One request per site at a time, robots.txt obeyed by default.

### What does it cost?

Two paid events:

- **"page"**: $1.50 per 1,000 pages, charged once per page returned with content. Larger Apify plans pay less per page (shown on the Pricing tab).
- **"search"**: $0.004 for each page of Google results read, on every plan. That is one per search query, or two when you ask for more than about 7 results. A search Google refuses is not charged, and links you paste have no search charge.

So the example above (one query, three pages) costs about $0.0085. Blocked, robots-denied, missing, timed-out and empty pages, unchanged pages skipped by **Only pages that changed**, and the summary row are free.

The run stops cleanly at your maximum charge and keeps everything read so far.

**Free Apify plan:** up to 50 pages and 10 searches per run. Any paid Apify plan removes the limit.

### Which inputs can I use?

Up front: **Search query** (`query`, one per line), **Page links** (`urls`), **Results per query** (`maxResults`, 1 to 20, default 3), **Output format** (`outputFormat`: `markdown`, `text`, `html` or `markdown+text`), **Open pages in a browser** (`renderJs`: `auto`, `never` or `always`) and **Only pages that changed** (`onlyChanged`).

Advanced: `country` (Google's country, default `us`), `language`, `maxCharsPerPage` (default 30,000; 0 = no limit), `chunkSize` (in tokens, about 4 characters each; 0 = no chunks), `includeLinks`, `removeSelectors` (CSS selectors to drop), `respectRobots` (default on) and `timeoutPerPageSecs` (default 30).

Inputs written for other page-reading tools also work: `queries`, `searchTerms` and `q` for the query; `startUrls` (plain links or `{"url": ...}`) and `url` for links; `maxItems` or `maxPages` to cap the pages read; `outputFormats` as a list; and `scrapingTool` (`raw-http` = never open a browser, `browser-playwright` = always).

### Why was a page marked robots-denied?

A site's robots.txt file says which pages crawlers may read. With **Obey robots.txt** on (the default), pages it disallows are not opened and come back free as `robots-denied`. If a site's robots.txt cannot be fetched because of a server error, its pages are treated as disallowed until it recovers. Turn the option off only for pages you have the right to read.

### What happens when something goes wrong?

- Bad input (no query and no links, an unknown country) ends the run with a message and charges nothing.
- If Google refuses a search, the links you gave are still read, and the run ends with a message naming the searches to re-run.
- A page behind a bot check or a sign-in screen comes back as `blocked`, free. The Actor never signs in. A few large sites with strong bot protection (some news, recipe and software-review sites) refuse cloud servers outright; expect those as `blocked` rows rather than content.
- If the run's time limit is near, it stops early, saves everything read and counts the rest as not read.

### Can I call it from an agent or my own code?

Yes. It works through the Apify API, the [Apify MCP server](https://mcp.apify.com/) and the Apify client libraries, with the same input as above. A one-query run with 3 results returns in well under a minute, so an agent can call it mid-conversation.

### Is it legal to read these pages?

The Actor reads public pages, the same ones anyone sees without signing in, and obeys robots.txt by default. It does not collect authors, email addresses or phone numbers as separate fields. You are responsible for how you use the content, for respecting each site's copyright and terms, and for following the laws that apply to you.

### Questions or problems?

Open an issue on the Issues tab and we will answer within a day. If the Actor helped, a rating on the Store helps other people find it.

# Changelog

This Actor's version history is a separate document: https://apify.com/locaihost/web-fetch/changelog.md

# Actor input Schema

## `query` (type: `string`):

Searched on Google; the top results are opened and read. One query per line for several. A link typed here is read directly. Leave empty to read only the links below.

## `urls` (type: `array`):

Pages to read directly, one per line: web pages, PDFs or Word files. Bare domains such as example.com get https:// added. Up to 1,000.

## `maxResults` (type: `integer`):

How many of Google's top results to read for each query (1 to 20).

## `outputFormat` (type: `string`):

What each row carries. Markdown keeps headings, lists, links, code blocks and tables.

## `renderJs` (type: `string`):

Auto reads every page with a plain download first and opens a browser only when the page has almost no text without scripts.

## `onlyChanged` (type: `boolean`):

Skip pages whose content is the same as when this Actor last returned them. Skipped pages are listed in the free summary row and never charged. Good for a daily schedule.

## `country` (type: `string`):

Two-letter country code Google searches from, such as us, gb, de or sg.

## `language` (type: `string`):

Language code such as en, de or pt-BR, for Google and for pages that have several languages. Leave empty for the country's own language.

## `maxCharsPerPage` (type: `integer`):

Longer pages are cut at a paragraph and marked truncated. 0 = no limit.

## `chunkSize` (type: `integer`):

Also split each page into chunks of about this many tokens (1 token is about 4 characters), cut at headings and paragraphs, each with its heading path. 0 = no chunks; 100 to 8,000 otherwise.

## `includeLinks` (type: `boolean`):

Add every link on the page (address and text).

## `removeSelectors` (type: `array`):

CSS selectors removed before the content is read, such as .newsletter-box. Menus, footers, cookie banners and ads are removed already.

## `respectRobots` (type: `boolean`):

Skip pages a site's robots.txt asks crawlers not to read. They come back free with status robots-denied.

## `timeoutPerPageSecs` (type: `integer`):

A page that takes longer comes back free with status timeout.

## Actor input object example

```json
{
  "query": "apify actor pricing pay per event",
  "urls": [
    "https://docs.apify.com/platform/actors"
  ],
  "maxResults": 3,
  "outputFormat": "markdown",
  "renderJs": "auto",
  "onlyChanged": false,
  "country": "us",
  "maxCharsPerPage": 30000,
  "chunkSize": 0,
  "includeLinks": false,
  "respectRobots": true,
  "timeoutPerPageSecs": 30
}
```

# Actor output Schema

## `pages` (type: `string`):

Every page read: status, title, word count, Markdown or text, metadata, chunks and the search result it came from.

## `summaryRow` (type: `string`):

The free summary row: searches run, pages read, counts by status and pages skipped as unchanged.

## `summary` (type: `string`):

Counts, Google and browser use, and cost.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "apify actor pricing pay per event"
};

// Run the Actor and wait for it to finish
const run = await client.actor("locaihost/web-fetch").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "query": "apify actor pricing pay per event" }

# Run the Actor and wait for it to finish
run = client.actor("locaihost/web-fetch").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "apify actor pricing pay per event"
}' |
apify call locaihost/web-fetch --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,locaihost/web-fetch"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/8lHqSoyJ7GqP0sPZ5/builds/MDy69rhBoViEekRpP/openapi.json
