# Marks & Spencer Scraper (`toludare/marks-and-spencer-scraper`)

Scrape the multinational British retailer, Marks & Spencer. Export names, prices, ratings, offers, images, and more by inputting your search inputs into the actor. Output extracted data in formats such as HTML, JSON, CSV, Excel, or XML.

- **URL**: https://beta-securitybyobscurity.apify.com/toludare/marks-and-spencer-scraper.md
- **Developed by:** [tolu.](https://beta-securitybyobscurity.apify.com/toludare) (community)
- **Categories:** E-commerce
- **Stats:** 6 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

# README

## Marks & Spencer Scraper

Scrape the multinational British retailer, Marks & Spencer. Export names, prices, ratings, offers, images, and more by inputing your search inputs into the actor. Output extracted data in formats such as HTML, JSON, CSV, Excel, or XML.

### 👩‍🍳 Input 👩‍🍳

#### Fields

|Parameter|Type|Description|Default Value|
|:---------|:----|:-----------|:-------------:|
|searchInputs|array|Enter at most 10 products, codes or brands|-|
|sortBy|`relevance`|`newArrivals`|`bestSelling`|`priceLowHigh`|`priceHighLow`|`ratings`|Sort the results of each search input by one of these|`relevance`|
|maxResults|integer|Limit the number of results per search input. If the value is 0, all the results will be returned|200|
|country|`uk`|Select Country / Region|`uk`|
|proxy|object|Select proxies to be used by the crawler.|`No proxy`|

#### Example (JSON)

```json
{
    "country": "uk",
    "maxResults": 0,
    "proxy": {
        "useApifyProxy": false
    },
    "searchInputs": [
        "t-shirts",
        "Autograph",
        "T112337"
    ],
    "sortBy": "newArrivals"
}
```

### 🍖 Output 🍖

#### Fields

- `id` - unique M\&S ID
- `url` - product URL
- `productCode` - unique identifier assigned to the product
- `title` - title of the product
- `brand` - brand of the product
- `category` - category that the product belongs to on M\&S
- `rating` - rating of the product
- `reviewCount` - the number of reviews that the product has
- `price` - the price of the product on M\&S
- `offers` - discount offers that are currently available
- `image` - product and model image
  - `image.productImage` - image of the product
  - `image.modelImage` - image of the product on a model
- `imagesByColour` - product and model image, separated by colour available
  - `imagesByColour.colour` - available product colour
  - `imagesByColour.productImage` - product image
  - `imagesByColour.modelImage` - model image
- `searchInput` - the search input that generated this result

#### Example

```json
{
  "id": "60722807",
  "url": "https://www.marksandspencer.com//pure-cotton-textured-regular-fit-t-shirt/p/clp60722808",
  "productCode": "T417210E",
  "title": "Pure Cotton Textured Regular Fit T-Shirt",
  "brand": "M&S Collection",
  "category": "T-shirts",
  "rating": 4.7,
  "reviewCount": 24,
  "price": "£17.50",
  "offers": null,
  "image": {
    "productImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_Z4_X_EC_90",
    "modelImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_Z4_X_EC_0"
  },
  "imagesByColour": [
    {
      "colour": "WHITE MIX",
      "productImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_Z4_X_EC_90",
      "modelImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_Z4_X_EC_0"
    },
    {
      "colour": "GREY MIX",
      "productImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_T4_X_EC_90",
      "modelImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_T4_X_EC_0"
    },
    {
      "colour": "RED MIX",
      "productImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_B4_X_EC_90",
      "modelImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_B4_X_EC_0"
    },
    {
      "colour": "IVORY MIX",
      "productImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_Y8_X_EC_90",
      "modelImage": "https://assets.digitalcontent.marksandspencer.app/image/upload/SD_01_T41_7210E_Y8_X_EC_0"
    }
  ],
  "searchInput": "t-shirts"
}
```

### 💸 Cost 💸

This scraper is currently on the rental plan and would cost you $20/month, excluding Apify usage fees. Usage fees are extremely low, only ~$0.01 per 1000 results. **You would need to have scraped over 100k results to spend $1 in usage fees 😲**. We offer a 1-day free trial for testing and experimentation.

```
This cost estimation assumes that no proxies were used. However, the actor works fine without proxies.
```

***

This scraper is under active development and suggestions or feature requests will be greatly appreciated. If you have any or encounter any issues, feel free to open an issue at https://console.apify.com/actors/1YHvYV4kq2XbWEjJS/issues

If you prefer a custom solution, email me directly at isaactoluwani30@gmail.com.

Enjoy 💪

# Actor input Schema

## `searchInputs` (type: `array`):

Enter at most 10 products, codes or brands

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

Sort the results of each search input by

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

Limit the number of results per search input. If the value is `0`, all the results will be returned

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

Select Country / Region

## `proxy` (type: `object`):

Select proxies to be used by the crawler. Try running with no proxies first.

## Actor input object example

```json
{
  "searchInputs": [
    "t-shirts",
    "Autograph",
    "T112337"
  ],
  "sortBy": "relevance",
  "maxResults": 200,
  "country": "uk"
}
```

# 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 = {
    "searchInputs": [
        "t-shirts",
        "Autograph",
        "T112337"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("toludare/marks-and-spencer-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 = { "searchInputs": [
        "t-shirts",
        "Autograph",
        "T112337",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("toludare/marks-and-spencer-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "searchInputs": [
    "t-shirts",
    "Autograph",
    "T112337"
  ]
}' |
apify call toludare/marks-and-spencer-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=toludare/marks-and-spencer-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Marks & Spencer Scraper",
        "description": "Scrape the multinational British retailer, Marks & Spencer. Export names, prices, ratings, offers, images, and more by inputting your search inputs into the actor. Output extracted data in formats such as HTML, JSON, CSV, Excel, or XML.",
        "version": "1.0",
        "x-build-id": "LF0FYupKzj3uR9ncZ"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/toludare~marks-and-spencer-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-toludare-marks-and-spencer-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/toludare~marks-and-spencer-scraper/runs": {
            "post": {
                "operationId": "runs-sync-toludare-marks-and-spencer-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/toludare~marks-and-spencer-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-toludare-marks-and-spencer-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "searchInputs"
                ],
                "properties": {
                    "searchInputs": {
                        "title": "Search product, code or brand",
                        "maxItems": 10,
                        "uniqueItems": true,
                        "type": "array",
                        "description": "Enter at most 10 products, codes or brands",
                        "items": {
                            "type": "string"
                        }
                    },
                    "sortBy": {
                        "title": "Sort By",
                        "enum": [
                            "relevance",
                            "newArrivals",
                            "bestSelling",
                            "priceLowHigh",
                            "priceHighLow",
                            "ratings"
                        ],
                        "type": "string",
                        "description": "Sort the results of each search input by",
                        "default": "relevance"
                    },
                    "maxResults": {
                        "title": "Maximum Number of Results per Search Input",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Limit the number of results per search input. If the value is `0`, all the results will be returned",
                        "default": 200
                    },
                    "country": {
                        "title": "Country / Region",
                        "enum": [
                            "uk"
                        ],
                        "type": "string",
                        "description": "Select Country / Region",
                        "default": "uk"
                    },
                    "proxy": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Select proxies to be used by the crawler. Try running with no proxies first."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
