# Web Scraper for Any Website - CSV, JSON, Google Sheets (`xegheplimo/polite-listing-scraper`) Actor

Scrape any public website into clean CSV, JSON or Google Sheets rows. Handles product listings, category pages, directories and tables. Polite crawling (robots.txt, rate limits, retries), auto-detects cards and tables, exports clean rows with scrapedAt timestamps.

- **URL**: https://apify.com/xegheplimo/polite-listing-scraper.md
- **Developed by:** [TRAN XUAN DUY](https://apify.com/xegheplimo) (community)
- **Categories:** Developer tools, Automation, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.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/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

## Polite listing scraper (CSV/JSON)

Scrape public listing pages into clean rows — politely.

### What it does

- Fetches listing pages you point it at (category or search URLs).
- Respects `robots.txt`, waits **1 second** between requests, retries up to **3 times** on transient failures.
- Extracts one row per listing: `title`, `price`, `availability`, `rating`, `url`, `source_url` — plus `description` and `image_url` when the page provides them.
- Saves results to the run's dataset (JSON + CSV download links are in the output schema).

### How sites are detected

- `books.toscrape.com` uses a dedicated adapter.
- **Any other domain uses generic auto-detection mode**: the actor looks for a
  repeated listing structure on the page (product cards, item blocks, articles,
  or table rows appearing 3+ times with the same structure) and extracts the
  fields it can find.
- If a page has no detectable listing structure, the run returns **0 rows** for
  that URL with the message *"no listing items detected on this page — check the
  URL is a listing/category page"* — it never fabricates data.

### Input

| Field | Type | Description |
|---|---|---|
| `urls` | array | Listing pages to scrape (required) |
| `pages` | integer | Listing pages to crawl per URL (1–50, default 1) |
| `fields` | array | Optional column filter. Keywords map to canonical columns: `title`/`name` → `title`, `price`/`giá` → `price`, `stock`/`availability` → `availability`, `rating`/`star` → `rating`, `url`/`link` → `url`, `desc`/`mô tả` → `description`, `image`/`ảnh` → `image_url`. Empty (default) keeps every detected column. |

The request delay is fixed at 1 second and is not user-configurable — politeness is not
negotiable.

### Output

One dataset item per listing:

```json
{
  "title": "Example listing",
  "price": "1.250.000đ",
  "availability": "In stock",
  "rating": "3",
  "url": "https://example.com/listing/123",
  "description": "Short excerpt when present (generic mode)",
  "image_url": "https://example.com/img/123.jpg",
  "source_url": "https://example.com/category/page-1",
  "scrapedAt": "2026-11-20T08:45:00Z"
}
```

`title`, `price`, `availability`, `rating`, `url`, `source_url` are emitted for every
supported site; `description` and `image_url` are filled by generic mode when found.
`scrapedAt` records the UTC time each row was added to the Apify dataset.

Download the whole run as CSV: add `?format=csv` to the dataset items URL shown in the run output.

### Notes

- Only public data. No login walls, no CAPTCHA bypass, no personal data.
- If a site blocks automated access, the actor stops instead of trying to work around it.
- Tools only — no investment advice, no profit claims.

# Actor input Schema

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

Public pages that list items

## `pages` (type: `integer`):

How many listing pages to crawl per start URL (1-50). Requests are paced at 1 second and robots.txt is enforced.

## `fields` (type: `array`):

Optional column filter. Keywords map to canonical columns: title/name -> title, price/giá -> price, stock -> availability, rating/star -> rating, url/link -> url, desc/mô tả -> description, image/ảnh -> image_url. Leave empty to keep every detected column.

## Actor input object example

```json
{
  "urls": [
    "https://books.toscrape.com"
  ],
  "pages": 1,
  "fields": []
}
```

# Actor output Schema

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

All scraped listing rows for this run.

## `rowsCsv` (type: `string`):

Same rows in CSV format.

# 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 = {
    "urls": [
        "https://books.toscrape.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("xegheplimo/polite-listing-scraper").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 = { "urls": ["https://books.toscrape.com"] }

# Run the Actor and wait for it to finish
run = client.actor("xegheplimo/polite-listing-scraper").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 '{
  "urls": [
    "https://books.toscrape.com"
  ]
}' |
apify call xegheplimo/polite-listing-scraper --silent --output-dataset

```

## MCP server setup

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

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/HLLJX24Fitcb7Yaso/builds/M293Hqq4j5UYR4g2R/openapi.json
