# HTML Table Extractor (`kindliest_readiness/html-table-extractor`) Actor

Extract static HTML tables from a list of URLs and export one dataset item per table row.

- **URL**: https://apify.com/kindliest_readiness/html-table-extractor.md
- **Developed by:** [Ming Zhang](https://apify.com/kindliest_readiness) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 results

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/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

## HTML Table Extractor

Export tables from a list of web pages to an Apify dataset. The Actor reads static HTML over HTTP(S). It runs without a browser and does not execute JavaScript or load page assets. Tables rendered by JavaScript after page load are outside its scope.

### Input

| Field | Default | What it controls |
| --- | --- | --- |
| `startUrls` | Required | List of HTTP(S) page URLs. |
| `selector` | All tables | CSS selector that matches the table element, such as `#prices` or `main table.stats`. |
| `tableIndex` | All indices | Zero-based index among non-nested HTML tables in document order, before selector and visibility filtering. When both filters are supplied, the table must meet both. |

```json
{
  "startUrls": ["https://example.com/prices"],
  "selector": "main table.stats",
  "tableIndex": 0
}
```

### Output

The Actor writes one dataset item per data row. Each item contains the input `url`, the table's `tableIndex`, and one string field per expanded column. For example, a table with City and Sales headers could produce this row.

```json
{
  "url": "https://example.com/prices",
  "tableIndex": 0,
  "City": "Rome",
  "Sales / Q1": "10",
  "Sales / Q2": "20"
}
```

- Headers come from the visible `<thead>` rows or, when there is no visible table head, a first visible row made entirely of `<th>` cells. Multi-row labels are joined with `/`.
- Merged cells repeat their text across occupied columns or rows. Rowspans stay within their row group. Missing cells are empty strings.
- Unnamed columns use `column_1`, `column_2`, and so on. Duplicate names and collisions with `url` or `tableIndex` receive a numbered suffix such as `_2`.
- Nested tables contribute text to their containing cells. Elements marked `hidden`, `aria-hidden="true"`, or inline `display: none` are skipped. Visibility rules from stylesheets are outside the scope of the parser.

### Request behavior

- The Actor uses one request at a time with the user agent `OneRice-HTMLTableExtractor/0.1` and a 15-second timeout.
- HTML responses are limited to 5 MiB after decompression. The Actor skips tables whose expanded grid would exceed 1,000,000 cells. Failed pages and skipped tables are logged.
- Users are responsible for checking and following each site's `robots.txt` and access rules. The Actor does not fetch or enforce `robots.txt`.

### Pricing

Pay per result at **$1 per 1,000 extracted rows**. When publishing, the owner sets the Apify pay-per-event price to **$0.001** for the `apify-default-dataset-item` event. It bills one result for each row written to the default dataset. [Apify pay-per-event documentation](https://docs.apify.com/actors/monetize/pay-per-event#use-apify-default-dataset-item)

### Local development

Use Node.js 24 or newer. Run `npm install`, then `npm test` for offline tests with HTML fixtures. To run the Actor locally, place input JSON in `storage/key_value_stores/default/INPUT.json` and run `npm start`.

The Dockerfile uses Apify’s Node.js base image. [Apify Dockerfile documentation](https://docs.apify.com/actors/development/actor-definition/dockerfile)

# Actor input Schema

## `startUrls` (type: `array`):

HTTP or HTTPS page URLs. Tables must be present in the static HTML response.

## `selector` (type: `string`):

Optional CSS selector that matches table elements, such as #results or main table.stats.

## `tableIndex` (type: `integer`):

Optional zero-based index among non-nested tables in page order, before selector filtering.

## Actor input object example

```json
{
  "startUrls": [
    "https://onerice.getvea.life/pagewatch/"
  ]
}
```

# Actor output Schema

## `rows` (type: `string`):

No description

# 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 = {
    "startUrls": [
        "https://onerice.getvea.life/pagewatch/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kindliest_readiness/html-table-extractor").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 = { "startUrls": ["https://onerice.getvea.life/pagewatch/"] }

# Run the Actor and wait for it to finish
run = client.actor("kindliest_readiness/html-table-extractor").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 '{
  "startUrls": [
    "https://onerice.getvea.life/pagewatch/"
  ]
}' |
apify call kindliest_readiness/html-table-extractor --silent --output-dataset

```

## MCP server setup

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

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/21mS0F6j7iaACLfmA/builds/LV9yXEziAu2qhccHk/openapi.json
