Avito Scraper logo

Avito Scraper

Community
Ascard

Модульный scraper для Avito с поддержкой CLI, MCP сервера и прокси.

PublisherAscard
Repositorymcp-avito
LanguageTypeScript
Forks
6
Stars
54
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    Avito Scraper exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    54 stars and 6 forks from the linked repository.

Avito Scraper

Модульный scraper для Avito с поддержкой CLI, MCP сервера и прокси.

📚 Документация: USAGE.md | PLAN.md

Возможности

✅ MVP (реализовано):

  • Поиск товаров с фильтрацией
  • Получение детальной информации об объявлении
  • CLI интерфейс
  • Вывод в консоль (таблица) и JSON
  • Anti-detection (user-agent, случайные задержки)
  • Stealth режим браузера
  • Ручное решение капчи (в видимом режиме)

✅ Прокси (реализовано):

  • Поддержка HTTP/HTTPS/SOCKS4/SOCKS5 ✅
  • Авторизация (username:password) ✅
  • SOCKS5 auth через proxy-chain ✅
  • 3 стратегии ротации: sequential/random/round-robin ✅
  • Автоматическая ротация каждые N запросов ✅
  • Отключение неработающих прокси (round-robin) ✅
  • Загрузка из файла ✅

✅ Пагинация (реализовано):

  • Итератор для поиска по всем страницам (search-all) ✅

✅ MCP Server (реализовано):

  • MCP сервер для интеграции с Claude Desktop и opencode ✅
  • 3 инструмента: avito_search, avito_get_details, avito_search_all ✅
  • Автоматическое переиспользование браузера ✅
  • См. docs/MCP_SETUP.md ✅

🚧 В разработке:

  • Anti-captcha интеграция (anti-captcha.com API)
  • Поддержка прокси в MCP сервере через переменные окружения

Установка

bash
pnpm install

Playwright browsers установятся автоматически при установке зависимостей.

Использование

CLI

Поиск товаров:

bash
# Базовый поиск
pnpm dev search "Samsung SSD 2TB"

# С фильтрами
pnpm dev search "Samsung SSD 2TB" --price-max 15000 --sort price_asc

# Сохранить результаты в JSON
pnpm dev search "Samsung SSD" --price-max 15000 --output results.json

# Без headless режима (показать браузер)
pnpm dev search "Samsung SSD" --headless false

# С прокси
pnpm dev search "Samsung SSD" --price-max 15000 --proxy-file config/proxies.txt

# С прокси и ротацией
pnpm dev search "Samsung SSD" \
  --price-max 15000 \
  --proxy-file config/proxies.txt \
  --proxy-rotation round-robin \
  --proxy-rotate-every 10

Получить детали объявления:

bash
# Вывод в консоль
pnpm dev details "https://www.avito.ru/item/12345678"

# Сохранить в JSON
pnpm dev details "https://www.avito.ru/item/12345678" --output item.json

Поиск по всем страницам:

bash
pnpm dev search-all "Samsung SSD" --output all-results.json --price-max 15000

Программный API

typescript
import { AvitoScraper } from './src/core/scraper.js';

const scraper = new AvitoScraper({
  headless: true,
  timeout: 30000,
  delayMs: [1000, 3000],
});

// Поиск
const results = await scraper.search({
  query: 'Samsung SSD 2TB',
  priceMax: 15000,
  sort: 'price_asc',
});

console.log(results);

// Детали
const details = await scraper.getItemDetails('https://www.avito.ru/item/12345678');
console.log(details);

// Закрыть браузер
await scraper.close();

MCP Server (Claude Desktop / opencode)

Быстрая настройка:

  1. Собрать проект:
bash
pnpm install && pnpm build
  1. Добавить в claude_desktop_config.json:
json
{
  "mcpServers": {
    "avito-scraper": {
      "command": "node",
      "args": ["C:\\Temp\\mcp-avito\\dist\\mcp\\server.js"],
      "env": {
        "CHROME_EXECUTABLE_PATH": "C:\\Temp\\mcp-avito\\chrome-win64\\chrome.exe"
      }
    }
  }
}
  1. Перезапустить Claude Desktop

Использование в Claude Desktop:

Найди Samsung SSD до 15000 рублей на Avito

Claude автоматически вызовет avito_search и покажет результаты.

MCP Server (opencode)

opencode использует проектный opencode.json (уже в репозитории):

json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "avito": {
      "type": "local",
      "command": ["node", "dist/mcp/server.js"],
      "enabled": true,
      "env": {
        "CHROME_EXECUTABLE_PATH": "C:\\_develop\\_neuro\\mcp-avito\\chrome-win64\\chrome.exe"
      }
    }
  }
}

Перед запуском соберите проект (pnpm build) и перезапустите opencode — конфиг читается при старте. После этого в opencode появятся инструменты avito_search, avito_get_details, avito_search_all.

📚 Полная инструкция: docs/MCP_SETUP.md

Примеры

Найти Samsung SSD до 15000₽:

bash
pnpm dev search "Samsung SSD 2TB M.2 server" \
  --price-max 15000 \
  --sort price_asc \
  --output ssd-results.json

Мониторинг цен:

bash
# Сохранять результаты с датой
pnpm dev search "Samsung PM983" \
  --price-max 15000 \
  --output "output/ssd-$(date +%Y%m%d).json"

Структура проекта

avito-scraper/
├── src/
│   ├── core/
│   │   ├── scraper.ts       # Основной scraper
│   │   ├── browser.ts       # Управление браузером
│   │   ├── parser.ts        # Парсинг HTML
│   │   └── types.ts         # TypeScript типы
│   ├── plugins/
│   │   └── output/
│   │       ├── console.ts   # Вывод в консоль
│   │       └── json.ts      # Сохранение в JSON
│   ├── utils/
│   │   ├── delays.ts        # Случайные задержки
│   │   ├── user-agents.ts   # User-agent pool
│   │   └── url-builder.ts   # Построение URL
│   └── cli.ts               # CLI интерфейс
├── config/
│   └── proxies.txt          # Список прокси (будущее)
├── opencode.json            # MCP-конфигурация для opencode
└── output/                  # Выходные файлы

Опции

ScraperOptions

typescript
{
  headless?: boolean;         // Headless режим (default: true)
  timeout?: number;           // Таймаут запросов (default: 30000ms)
  retries?: number;           // Повторные попытки (default: 3)
  delayMs?: [number, number]; // Задержка [min, max] (default: [1000, 3000])
  userAgent?: string;         // Custom user-agent
  captchaTimeoutMs?: number;  // Сколько ждать ручного решения капчи (default: 120000ms)
  captchaPollMs?: number;     // Как часто проверять решена ли капча (default: 3000ms)
  manualCaptchaFallback?: boolean; // При капче в headless — перезапустить браузер в видимом режиме (default: true)
}

SearchFilters

typescript
{
  query: string;              // Поисковый запрос (обязательно)
  priceMin?: number;          // Минимальная цена
  priceMax?: number;          // Максимальная цена
  locationId?: number;        // ID региона
  page?: number;              // Номер страницы
  sort?: string;              // Сортировка: date | price_asc | price_desc
}

Anti-detection

Scraper использует несколько техник для обхода детекции:

  • ✅ Случайные user-agents
  • ✅ Случайные задержки между запросами
  • ✅ Stealth mode (скрытие webdriver)
  • ✅ Реалистичные настройки браузера (viewport, locale, timezone)
  • ✅ Прокси поддержка (HTTP/HTTPS/SOCKS4/SOCKS5 с авторизацией)
  • ✅ Ротация прокси (3 стратегии)
  • ✅ Ручное решение captcha (в non-headless режиме: попап в окне браузера + автопроверка)
  • ✅ Автопереход в видимый режим при капче в headless (manualCaptchaFallback)
  • 🚧 Решение captcha автоматическое (в планах)

Roadmap

См. подробный план разработки в docs/PLAN.md

Следующая версия (v1.1.0):

  • MCP сервер для интеграции с Claude Desktop
  • MCP tools: avito_search, avito_get_details, avito_search_all
  • Конфигурация для Claude Desktop
  • Интеграция с opencode (проектный opencode.json)

Будущие версии:

  • Anti-captcha.com API интеграция
  • Web UI dashboard
  • Мониторинг цен и уведомления
  • CSV/Excel экспорт

Troubleshooting

Ошибка "Captcha detected":

  • В headless режиме при включённом manualCaptchaFallback (по умолчанию) браузер автоматически перезапустится в видимом окне — решите капчу там
  • Запустите CLI с --headless false — в окне браузера появится попап с просьбой решить капчу вручную
  • Уменьшите частоту запросов
  • Используйте прокси
  • Добавьте anti-captcha solver

Пустые результаты:

  • Проверьте поисковый запрос
  • Запустите с --headless false для визуальной проверки
  • Проверьте селекторы в parser.ts (Avito может изменить HTML)

Браузер не запускается:

  • Убедитесь что установлен Chromium: npx playwright install chromium

Лицензия

MIT

Disclaimer

Этот инструмент предназначен только для образовательных целей. Использование scraping'а может нарушать Terms of Service Avito. Используйте на свой риск.

Installation

TypingMind
{
  "mcpServers": {
    "mcp-avito": {
      "command": "node",
      "args": [
        "dist/mcp/server.js"
      ]
    }
  }
}

Use Avito Scraper MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Avito Scraper is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Avito Scraper as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Avito Scraper MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mcp-avito": {
      "command": "npx",
      "args": [
        "-y",
        "avito-scraper"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Avito Scraper MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Avito Scraper MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Avito Scraper to help me with this task?
Avito Scraper
Sure. I read it.
Here is what I found using Avito Scraper.

Frequently asked questions

What is the Avito Scraper MCP server used for?

Avito Scraper is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Avito Scraper MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Avito Scraper with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Avito Scraper MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Avito Scraper connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Avito Scraper MCP to TypingMind?

Avito Scraper runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Avito Scraper MCP provide in TypingMind?

Avito Scraper exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Avito Scraper MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Avito Scraper requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇