# Amazon Products Scraper (Brasil) (`citrine_osmosis/amazon-products-scraper-brasil`) Actor

Um aplicativo que coleta automaticamente (faz scraping) e estrutura dados de produtos disponíveis publicamente a partir de anúncios da Amazon para análise e monitoramento.

- **URL**: https://apify.com/citrine\_osmosis/amazon-products-scraper-brasil.md
- **Developed by:** [Lucas Missalia](https://apify.com/citrine_osmosis) (community)
- **Categories:** E-commerce
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

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

## 🛒 Amazon Product Scraper (Optimized) — Apify Actor

An Apify Actor that extracts structured product data from Amazon search result pages using **Playwright (async Chromium)**, with a focus on **high performance and stability** on the Apify platform. citeturn4search1turn3file4

> **Performance-first version:** this iteration adds **concurrency**, **resource blocking**, and **single-pass DOM extraction** to reduce Playwright overhead and prevent slowdowns/freezes under load. citeturn3file4

---

### 📦 Features

- Scrapes Amazon search result pages for product listings. citeturn4search1
- Extracts rich product data including prices, ratings, delivery info, stock hints, and optional specs. citeturn4search1turn3file4
- Automatically handles cookie consent banners (best-effort). citeturn4search1turn3file4
- Triggers lazy-loaded content with a lightweight scroll. citeturn4search1turn3file4
- **Optimized for Apify performance**:
  - **Concurrent workers** (multiple pages in parallel). citeturn3file4
  - **Blocks heavy resources** (images/fonts/styles/media) to reduce CPU/RAM and speed navigation. citeturn3file4
  - **Single `page.evaluate()` extraction** to avoid hundreds of Playwright round-trips per page. citeturn3file4
- Detects Kindle Unlimited info (when present) and flags international purchase availability (best-effort). citeturn4search1turn3file4
- Outputs clean, structured JSON data via Apify's dataset. citeturn4search1turn3file4

---

### 🗂️ Output

#### Output model

This optimized version pushes **one dataset item per product** (in batches) and includes the originating search URL in `sourceUrl`. citeturn3file4

#### Example item

```json
{
  "sourceUrl": "https://www.amazon.com/s?k=laptop",
  "name": "Product Title",
  "asin": "B09XYZ1234",
  "rate": "4.5 out of 5 stars",
  "rateCount": "12,345 ratings",
  "description": "Short editorial or badge description",
  "price": "$499.99",
  "delivery": "Monday, Apr 22",
  "shippingInformation": "Free delivery Monday, Apr 22",
  "fastestDelivery": "Fastest delivery: Tomorrow",
  "internationalPurchase": false,
  "thumbnail": "https://m.media-amazon.com/images/...",
  "link": "https://www.amazon.com/dp/B09XYZ1234",
  "stockDetails": "Only 20 left in stock - order soon.",
  "details": {
    "screenSize": "15.6 Inches",
    "ram": "16 GB",
    "kindleUnlimited": "https://www.amazon.com/...",
    "message": "Read for free with Kindle Unlimited"
  }
}
````

**Notes**

- `stockDetails` and `details` are **optional** and appear only when the product listing includes those blocks. citeturn4search1turn3file4
- Only products that have **both a name and a price** are included in the output. citeturn4search1turn3file4

***

### ⚙️ Input Configuration

Configure the Actor via the Apify input UI or by passing JSON.

#### Fields

- `start_urls` *(array)* — List of Amazon search URLs to scrape.
  - Default: `[{"url": "https://www.amazon.com/s?k=spider+man+comics"}]` citeturn3file4
- `max_concurrency` *(number)* — Number of parallel workers/pages.
  - Default: `4` citeturn3file4
- `max_retries` *(number)* — Retries per URL on timeout/error.
  - Default: `2` citeturn3file4
- `navigation_timeout_ms` *(number)* — Navigation timeout in milliseconds.
  - Default: `30000` citeturn3file4

#### Example Input

```json
{
  "start_urls": [
    { "url": "https://www.amazon.com/s?k=mechanical+keyboard" },
    { "url": "https://www.amazon.com/s?k=gaming+headset" }
  ],
  "max_concurrency": 4,
  "max_retries": 2,
  "navigation_timeout_ms": 30000
}
```

***

### 🛠️ Tech Stack

- **Apify SDK (Python)** — Actor lifecycle, request queue, dataset output. citeturn4search1
- **Playwright (async)** — Headless Chromium browser automation. citeturn4search1

***

### 🔍 How It Works

1. **Initialization** — The Actor reads `start_urls` from the input and seeds a request queue. citeturn4search1turn3file4
2. **Browser + Context** — A headless Chromium browser is launched with a realistic user-agent and viewport. citeturn4search1turn3file4
3. **Performance routing** — Requests are intercepted and heavy resources are blocked (fonts, stylesheets, media, images). citeturn3file4
4. **Concurrent processing** — Multiple workers reuse pages and pull URLs from the queue concurrently. citeturn3file4
5. **Page processing** — For each URL, the Actor:
   - Navigates to the page and accepts cookie banners if present (best-effort). citeturn4search1turn3file4
   - Waits for the Amazon search result grid to appear.
   - Performs a light scroll to trigger lazy-loaded product cards. citeturn4search1turn3file4
6. **Data extraction** — Extracts all product cards in a **single `page.evaluate()`** call and post-processes fields (e.g., Kindle Unlimited link). citeturn3file4
7. **Output** — Structured product items are pushed to the Apify dataset (batched). citeturn3file4

***

### 🚀 Performance Tips

- Start with `max_concurrency = 2–4` and increase gradually based on your Actor’s CPU/RAM. citeturn3file4
- If you observe timeouts, increase `navigation_timeout_ms` and/or reduce concurrency. citeturn3file4
- Blocking heavy resources improves speed, but if you need higher fidelity (e.g., guaranteed thumbnails), consider allowing images by removing `image` from the blocked types. citeturn3file4

***

### ⚠️ Limitations & Notes

- Amazon actively detects and blocks scrapers. This Actor uses a realistic user-agent and scroll behavior to mitigate this, but results may vary depending on the region and Amazon's current anti-bot policies. citeturn4search1turn3file4
- Amazon page layout and selectors change frequently; you may need to update selectors inside the extraction script. citeturn3file4
- Intended for **search result pages** (e.g., `/s?k=...`), not product detail pages. citeturn3file4

***

### 📄 License / Compliance

This project is intended for personal and educational use. Always comply with Amazon’s Terms of Service and applicable laws when scraping. citeturn4search1

# Actor input Schema

## `start_urls` (type: `array`):

URLs to start with

## `max_concurrency` (type: `integer`):

defines the maximum number of pages or browser contexts crawled simultaneously

## `max_retries` (type: `integer`):

configuration option that defines the maximum number of times a failed test will be automatically re-executed before being marked as finally failed

## `navigation_timeout_ms` (type: `integer`):

the maximum time (in milliseconds) the framework will wait for a page navigation event to complete before throwing a TimeoutError

## Actor input object example

```json
{
  "start_urls": [
    {
      "url": "https://www.amazon.com/s?k=laptop"
    }
  ],
  "max_concurrency": 4,
  "max_retries": 2,
  "navigation_timeout_ms": 30000
}
```

# Actor output Schema

## `results` (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 = {
    "start_urls": [
        {
            "url": "https://www.amazon.com/s?k=laptop"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("citrine_osmosis/amazon-products-scraper-brasil").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 = { "start_urls": [{ "url": "https://www.amazon.com/s?k=laptop" }] }

# Run the Actor and wait for it to finish
run = client.actor("citrine_osmosis/amazon-products-scraper-brasil").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 '{
  "start_urls": [
    {
      "url": "https://www.amazon.com/s?k=laptop"
    }
  ]
}' |
apify call citrine_osmosis/amazon-products-scraper-brasil --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=citrine_osmosis/amazon-products-scraper-brasil",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Amazon Products Scraper (Brasil)",
        "description": "Um aplicativo que coleta automaticamente (faz scraping) e estrutura dados de produtos disponíveis publicamente a partir de anúncios da Amazon para análise e monitoramento.",
        "version": "0.1",
        "x-build-id": "ZNAPKXQpWuhZnNqZR"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/citrine_osmosis~amazon-products-scraper-brasil/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-citrine_osmosis-amazon-products-scraper-brasil",
                "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/citrine_osmosis~amazon-products-scraper-brasil/runs": {
            "post": {
                "operationId": "runs-sync-citrine_osmosis-amazon-products-scraper-brasil",
                "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/citrine_osmosis~amazon-products-scraper-brasil/run-sync": {
            "post": {
                "operationId": "run-sync-citrine_osmosis-amazon-products-scraper-brasil",
                "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": [
                    "start_urls"
                ],
                "properties": {
                    "start_urls": {
                        "title": "Start URLs",
                        "type": "array",
                        "description": "URLs to start with",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "max_concurrency": {
                        "title": "max_concurrency",
                        "type": "integer",
                        "description": "defines the maximum number of pages or browser contexts crawled simultaneously",
                        "default": 4
                    },
                    "max_retries": {
                        "title": "max_retries",
                        "type": "integer",
                        "description": "configuration option that defines the maximum number of times a failed test will be automatically re-executed before being marked as finally failed",
                        "default": 2
                    },
                    "navigation_timeout_ms": {
                        "title": "navigation_timeout_ms",
                        "type": "integer",
                        "description": "the maximum time (in milliseconds) the framework will wait for a page navigation event to complete before throwing a TimeoutError",
                        "default": 30000
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
