# Thewarehouse Category Parser Spider (`getdataforme/thewarehouse-category-parser-spider`) Actor

- **URL**: https://apify.com/getdataforme/thewarehouse-category-parser-spider.md
- **Developed by:** [GetDataForMe](https://apify.com/getdataforme) (community)
- **Categories:** AI, Automation, E-commerce
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $9.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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Apify Template for Scrapy Spiders

This repository serves as a template for deploying Scrapy spiders to Apify. It is automatically updated by a GitHub Actions workflow in the central repository (`getdataforme/central_repo`) when changes are pushed to spider files in `src/spiders/` or `src/custom/`. Below is an overview of the automated tasks performed to keep this repository in sync.

### Automated Tasks

The following tasks are executed by the GitHub Actions workflow when a spider file (e.g., `src/spiders/example/example_parser_spider.py`) is modified in the central repository:

1. **Repository Creation**:
   - Creates a new Apify repository (e.g., `example_apify`) from this template (`apify_template`) using the GitHub API, if it doesn't already exist.
   - Grants push permissions to the `scraping` team in the `getdataforme` organization.

2. **Spider File Sync**:
   - Copies the modified spider file (e.g., `example_parser_spider.py`) from the central repository to `src/spiders/` in this repository.
   - Copies the associated `requirements.txt` (if present) from the spider's directory (e.g., `src/spiders/example/`) to the root of this repository.

3. **Input Schema Generation**:
   - Runs `generate_input_schema.py` to create `.actor/input_schema.json`.
   - Parses the spider's `__init__` method (e.g., `def __init__(self, location:str, item_limit:int=100, county:str="Japan", *args, **kwargs)`) to generate a JSON schema.
   - Supports types: `string`, `integer`, `boolean`, `number` (for Python `str`, `int`, `bool`, `float`).
   - Uses `prefill` for strings and `default` for non-strings, with appropriate `editor` values (`textfield`, `number`, `checkbox`).
   - Marks parameters without defaults (e.g., `location`) as `required`.

4. **Main Script Update**:
   - Runs `update_main.py` to update `src/main.py`.
   - Updates the `actor_input` section to fetch input values matching the spider's `__init__` parameters (e.g., `location`, `item_limit`, `county`).
   - Updates the `process.crawl` call to pass these parameters to the spider (e.g., `process.crawl(Spider, location=location, item_limit=item_limit, county=county)`).
   - Preserves existing settings, comments, and proxy configurations.

5. **Actor Configuration Update**:
   - Updates `.actor/actor.json` to set the `name` field based on the repository name, removing the `_apify` suffix (e.g., `example_apify` → `example`).
   - Uses `jq` to modify the JSON file while preserving other fields (e.g., `title`, `description`, `input`).

6. **Commit and Push**:
   - Commits changes to `src/spiders/$spider_file`, `requirements.txt`, `.actor/input_schema.json`, `src/main.py`, and `.actor/actor.json`.
   - Pushes the changes to the `main` branch of this repository.

### Repository Structure

- `src/spiders/`: Contains the Scrapy spider file (e.g., `example_parser_spider.py`).
- `src/main.py`: Main script to run the spider with Apify Actor integration.
- `.actor/input_schema.json`: JSON schema defining the spider's input parameters.
- `.actor/actor.json`: Actor configuration with the repository name and metadata.
- `requirements.txt`: Python dependencies for the spider.
- `Dockerfile`: Docker configuration for running the Apify Actor.

### Prerequisites

- The central repository (`getdataforme/central_repo`) must contain:
  - `generate_input_schema.py` and `update_main.py` in the root.
  - Spider files in `src/spiders/` or `src/custom/` with a valid `__init__` method.
- The GitHub Actions workflow requires a `GITHUB_TOKEN` with repository creation and write permissions.
- `jq` and `python3` are installed in the workflow environment.

### Testing

To verify the automation:
1. Push a change to a spider file in `src/spiders/` or `src/custom/` in the central repository.
2. Check the generated Apify repository (e.g., `getdataforme/example_apify`) for:
   - Updated `src/spiders/$spider_file`.
   - Correct `input_schema.json` with parameters matching the spider's `__init__`.
   - Updated `src/main.py` with correct `actor_input` and `process.crawl` lines.
   - Updated `.actor/actor.json` with the correct `name` field.

### Notes

> **Warning**: This Apify actor repository is automatically generated and updated by the GitHub Actions workflow in `getdataforme/central_repo`. **Do not edit this repository directly**. To modify the spider, update the corresponding file in `src/spiders/` or `src/custom/` in the central repository, and the workflow will sync changes to this repository, including:
> - Copying the spider file to `src/spiders/`.
> - Generating `.actor/input_schema.json` based on the spider’s `__init__` parameters.
> - Updating `src/main.py` with correct input handling and spider execution.
> - Setting the `name` field in `.actor/actor.json` (e.g., `example` for `example_apify`).
>
> **Verification**: After the workflow completes, verify the actor by checking:
> - `src/spiders/$spider_file` matches the central repository.
> - `.actor/input_schema.json` includes all `__init__` parameters with correct types and defaults.
> - `src/main.py` has updated `actor_input` and `process.crawl` lines.
> - `.actor/actor.json` has the correct `name`.
> - Optionally, deploy the actor to Apify and test with sample inputs to ensure functionality.

- The workflow supports multiple spider types (`scrapy`, `hrequest`, `playwright`) based on the file path (`src/spiders/`, `src/custom/*/hrequest/`, `src/custom/*/playwright/`).
- Commits with `[apify]` in the message update only Apify repositories; `[internal]` updates only internal repositories; otherwise, both are updated.
- Ensure the spider's `__init__` uses supported types (`str`, `int`, `bool`, `float`) to avoid schema generation errors.

For issues, check the GitHub Actions logs in the central repository or contact the `scraping` team.

# Actor input Schema

## `Urls` (type: `array`):

The urls for the spider.
## `proxyConfiguration` (type: `object`):

Specifies proxy servers that will be used by the scraper in order to hide its origin.

## Actor input object example

```json
{
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
````

# 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 = {
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("getdataforme/thewarehouse-category-parser-spider").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 = { "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    } }

# Run the Actor and wait for it to finish
run = client.actor("getdataforme/thewarehouse-category-parser-spider").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 '{
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call getdataforme/thewarehouse-category-parser-spider --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=getdataforme/thewarehouse-category-parser-spider",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Thewarehouse Category Parser Spider",
        "description": null,
        "version": "0.0",
        "x-build-id": "V9E4JMLsMCYp8iRvS"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/getdataforme~thewarehouse-category-parser-spider/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-getdataforme-thewarehouse-category-parser-spider",
                "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/getdataforme~thewarehouse-category-parser-spider/runs": {
            "post": {
                "operationId": "runs-sync-getdataforme-thewarehouse-category-parser-spider",
                "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/getdataforme~thewarehouse-category-parser-spider/run-sync": {
            "post": {
                "operationId": "run-sync-getdataforme-thewarehouse-category-parser-spider",
                "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",
                "properties": {
                    "Urls": {
                        "title": "Urls",
                        "minItems": 1,
                        "type": "array",
                        "description": "The urls for the spider.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Specifies proxy servers that will be used by the scraper in order to hide its origin.",
                        "default": {
                            "useApifyProxy": true,
                            "apifyProxyGroups": [
                                "RESIDENTIAL"
                            ]
                        }
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
