# Plain-Text Stripper (`dr.skywalker/plain-text-stripper`) Actor

Strip web pages (or pasted text/markdown) down to clean raw text: HTML tags, scripts, styles, markdown artifacts, and excess whitespace removed. One dataset record per page plus a job summary. Ideal for building LLM-ready corpora and content pipelines.

- **URL**: https://apify.com/dr.skywalker/plain-text-stripper.md
- **Developed by:** [Luqin Wang](https://apify.com/dr.skywalker) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 strip job completeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Plain-Text Stripper

Strip web pages — or pasted text/markdown — down to clean raw text. HTML tags, scripts, styles, comments, markdown artifacts, and excess whitespace are removed; what survives is the page's own words in reading order. Ideal for building LLM-ready corpora, content pipelines, and readability preprocessing.

### Input

Source priority: **rawText** > **urlsFile** > **urlsUrl** > **urlsText**. The highest-priority non-empty source wins.

| Field | Description |
|---|---|
| `rawText` | Paste raw text or markdown to strip directly, without fetching any URL. |
| `urlsText` | Paste one URL per line (prefill: `https://example.com`). |
| `urlsUrl` | Public URL of a text file with one URL per line. |
| `urlsFile` | Upload a text file (`apify://` key-value-store reference). |
| `timeoutSec` | Per-page fetch timeout, 5–60s (default 20). |
| `maxUrls` | Max pages per run, 1–2000 (default 500). |

### Output

- **Dataset** — one record per stripped page/text: `url`, `finalUrl`, `status`, `text`, `charCount`, `wordCount`, `truncated`, `error`, `checkedAt`, plus stable `_recordId` / `_batchId` / `_seq` reconciliation IDs. Exportable as CSV/JSON.
- **SUMMARY.json** (key-value store) — `itemsPublished`, `pagesRequested`, `pagesProcessed`, `pageErrors`, `chargeLimitReached`, `unitsCharged`. Aggregates confirmed publications only.
- **Job receipt** — one `job-completion` record published after all page records when at least one page was published.

Non-text content (PDFs, images, …) gets an explanatory `error` record instead of text. Error records are published like any other page record and count toward `page-stripped`: the fetch and classification work was done. `pageErrors` in SUMMARY tracks how many.

### Billing (pay-per-event)

| Event | Price |
|---|---|
| `strip-completed` | $0.02 per job (primary) |
| `page-stripped` | $0.001 per page |

Publish-then-charge: each batch of records is published to the dataset first; only confirmed publications are ever charged, through persisted idempotency keys that are reused verbatim across retries and restarts. A crash between publication and charging leaves published-but-uncharged records (accepted revenue leak, never the reverse) — charging for undelivered work is impossible by construction.

### Safety

- SSRF-resistant fetching: DNS is resolved and pinned before connect; private/loopback/link-local targets are refused; redirects are followed manually (max 5) and re-validated per hop.
- Hard deadlines on every fetch, key-value-store access, and the publication boundary; the single-attempt raw POST boundary means one push is exactly one POST.
- Fail-closed billing: unknown pricing state, unvalidated event names, unconfirmed publication, or an ambiguous charge outcome all stop the run rather than risk a wrong bill.

# Actor input Schema

## `maxUrls` (type: `integer`):

Maximum number of pages to strip per run.

## `rawText` (type: `string`):

Paste raw text or markdown to strip directly, without fetching any URL. Takes priority over all URL sources.

## `timeoutSec` (type: `integer`):

How long to wait for each page before giving up.

## `urlsFile` (type: `string`):

Upload a text file with one URL per line. Used only when rawText is empty.

## `urlsText` (type: `string`):

Paste one URL per line. Used only when rawText, urlsFile, and urlsUrl are empty. Example: https://example.com

## `urlsUrl` (type: `string`):

Public URL of a text file with one URL per line. Used only when rawText and urlsFile are empty. Example: https://example.com/urls.txt

## Actor input object example

```json
{
  "maxUrls": 500,
  "timeoutSec": 20,
  "urlsText": "https://example.com"
}
```

# Actor output Schema

## `files` (type: `string`):

Key-value store with downloadable result files and summary.

## `results` (type: `string`):

Dataset with one item per stripped page/text.

# 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 = {
    "maxUrls": 500,
    "rawText": "",
    "timeoutSec": 20,
    "urlsFile": "",
    "urlsText": "https://example.com",
    "urlsUrl": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("dr.skywalker/plain-text-stripper").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 = {
    "maxUrls": 500,
    "rawText": "",
    "timeoutSec": 20,
    "urlsFile": "",
    "urlsText": "https://example.com",
    "urlsUrl": "",
}

# Run the Actor and wait for it to finish
run = client.actor("dr.skywalker/plain-text-stripper").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 '{
  "maxUrls": 500,
  "rawText": "",
  "timeoutSec": 20,
  "urlsFile": "",
  "urlsText": "https://example.com",
  "urlsUrl": ""
}' |
apify call dr.skywalker/plain-text-stripper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dr.skywalker/plain-text-stripper"
        }
    }
}
```

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/L2GJLYcaRaumcuWVX/builds/dCTf390bUyws3h84I/openapi.json
