# Books.toscrape.com Scraper - Book Catalog Data Extractor (`fervent_bus/books-toscrape-scraper`) Actor

Scrape book catalog data from books.toscrape.com including titles, prices, ratings, availability, and images. Perfect for testing and learning web scraping.

- **URL**: https://apify.com/fervent\_bus/books-toscrape-scraper.md
- **Developed by:** [Archit Khurana](https://apify.com/fervent_bus) (community)
- **Categories:** E-commerce, Developer tools
- **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.
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

## Books.toscrape.com Scraper

Scrape book catalog data from [books.toscrape.com](http://books.toscrape.com/) - a practice website designed for learning web scraping.

### Features

- 📚 Extracts complete book catalog data
- 💰 Captures prices, ratings, and availability
- 🖼️ Includes book images and URLs
- 🔄 Handles pagination automatically
- 🎯 Configurable result limits
- 🔒 Uses residential proxies for reliability

### Extracted Data

Each book record includes:

- **Title** - Full book title
- **Price** - Current price
- **Rating** - Star rating (One to Five)
- **Availability** - Stock status
- **Image URL** - Book cover image
- **Book URL** - Link to book detail page
- **Page Number** - Which catalog page it was found on

### Input Configuration

#### Start URL

The URL to begin scraping from.

- **Default**: `http://books.toscrape.com/`
- **Example**: `http://books.toscrape.com/catalogue/category/books/travel_2/index.html`

#### Maximum Results

Maximum number of books to scrape.

- **Default**: 100
- **Range**: 1-1000

### Usage Example

```json
{
  "startUrl": "http://books.toscrape.com/",
  "maxResults": 50
}
```

### Output Example

```json
{
  "title": "A Light in the Attic",
  "price": "£51.77",
  "rating": "Three",
  "availability": "In stock",
  "image_url": "http://books.toscrape.com/media/cache/2c/da/2cdad67c44b002e7ead0cc35693c0e8b.jpg",
  "book_url": "http://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
  "scraped_at": "http://books.toscrape.com/",
  "page_number": 1
}
```

### Cost

- **Per Result**: $0.005
- **Per Run**: $0.05
- **Example**: 100 books = $0.05 (run) + $0.50 (results) = $0.55

### About books.toscrape.com

This is a sandbox website specifically created for practicing web scraping. It contains 1000 books across 50 pages with no bot protection, making it perfect for testing scrapers.

### Notes

- Site has LIGHT protection (scraping-friendly)
- No authentication required
- Respects robots.txt
- Uses Apify residential proxies when available
- Suitable for learning and testing purposes

### Support

For issues or questions, please open an issue on the actor's page.

# Actor input Schema

## `category` (type: `string`):

Book category to scrape

## `minPrice` (type: `number`):

Minimum book price filter

## `maxPrice` (type: `number`):

Maximum book price filter

## `rating` (type: `integer`):

Filter books by minimum star rating (1-5)

## `availability` (type: `string`):

Stock availability filter

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

Maximum number of books to scrape

## `sortBy` (type: `string`):

Sort results by

## Actor input object example

```json
{
  "category": "All Books",
  "minPrice": 10,
  "maxPrice": 50,
  "rating": 3,
  "availability": "All",
  "maxResults": 100,
  "sortBy": "default"
}
```

# Actor output Schema

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

Complete dataset of scraped books

# 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 = {
    "category": "All Books",
    "minPrice": 0,
    "maxPrice": 100,
    "rating": 1,
    "availability": "All",
    "maxResults": 3,
    "sortBy": "default"
};

// Run the Actor and wait for it to finish
const run = await client.actor("fervent_bus/books-toscrape-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 = {
    "category": "All Books",
    "minPrice": 0,
    "maxPrice": 100,
    "rating": 1,
    "availability": "All",
    "maxResults": 3,
    "sortBy": "default",
}

# Run the Actor and wait for it to finish
run = client.actor("fervent_bus/books-toscrape-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 '{
  "category": "All Books",
  "minPrice": 0,
  "maxPrice": 100,
  "rating": 1,
  "availability": "All",
  "maxResults": 3,
  "sortBy": "default"
}' |
apify call fervent_bus/books-toscrape-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fervent_bus/books-toscrape-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/J0oJW0zBZ6i5tkABl/builds/h5dG3ZDF72pCSVCH8/openapi.json
