Async web scraper for ATB Market (Ukrainian grocery chain).
- Parse products by category
- Sync and async modes
- Extract: ID, title, brand, price, image, category, cashback status
- Parallel page fetching (async mode)
- 27 product categories supported
# Clone repository
git clone <repo-url>
cd atb_parser
# Install dependencies
uv sync
# Or via pip
pip install -r requirements.txtfrom parsers import ATBparser
parser = ATBparser()
# Parse category
products = parser.parse_category("economy")
# Interactive category selection
category_slug = parser.choose_category()
products = parser.parse_category(category_slug)
# Search products
results = parser.search_product("milk")import asyncio
from parsers import AsyncATBparser
async def main():
parser = AsyncATBparser(rate_limit_delay=0.3)
products = await parser.parse_category("economy")
print(f"Found {len(products)} products")
asyncio.run(main())Each product returns as dict:
{
"id": 12345,
"title": "Milk 2.5%",
"brand": "Galychyna",
"category": "Dairy products",
"price": 45.90,
"image_url": "https://...",
"product_link": "https://www.atbmarket.com/product/...",
"national_cashback": True
}Available categories in config.json:
- Economy (
economy) - New products (
novetly) - 7-day sale (
388-aktsiya-7-dniv) - Vegetables and fruits (
287-ovochi-ta-frukti) - Groceries (
285-bakaliya) - Dairy and eggs (
molocni-produkti-ta-ajca) - Alcohol (
292-alkogol-i-tyutyun) - Soft drinks (
294-napoi-bezalkogol-ni) - Cheese (
siri) - Meat (
maso) - Confectionery (
299-konditers-ki-virobi) - Fish and seafood (
353-riba-i-moreprodukti) - Bakery (
325-khlibobulochni-virobi) - Frozen products (
322-zamorozheni-produkti) - Coffee, tea (
kava-caj) - Chips, snacks (
cipsi-sneki) - Sausages and deli (
360-kovbasa-i-m-yasni-delikatesi) - Baby food (
339-dityache-kharchuvannya) - Japanese cuisine (
415-yapons-ka-kukhnya) - Ready meals (
502-kulinariya) - Kids products (
373-tovari-dlya-ditey) - Household chemicals (
308-pobutova-khimiya-ta-neprodovol-chi-tovari) - Hygiene and cosmetics (
290-gigiena-i-kosmetika) - Home goods (
358-tovari-dlya-domu) - Pet supplies (
389-kantselyars-ki-tovari) - Tobacco products (
479-tyutyunovi-virobi) - Gift cards (
sertifikati-ta-platizni-kartki) - Stationery (
389-kantselyars-ki-tovari)
Settings in config.json:
{
"base_url": "https://www.atbmarket.com/",
"base_url_catalog": "https://www.atbmarket.com/catalog/load-more-products/",
"categories": {
"Економія": "economy",
...
}
}Project includes SQLAlchemy async ORM with price history tracking.
Product table:
id(BigInt, PK) — ATB product IDtitle,brand,category— product metadatanational_cashback(Boolean) — cashback eligibilityimage_url,product_link— media links
PriceHistory table:
id(autoincrement PK)product_id(FK → products.id)price(Float)updated_at(DateTime, UTC)
Edit config.json to switch database:
{
"database_type": "sqlite", // or "postgres"
"db_host": "localhost",
"db_port": "5432",
"db_name": "atb_prices",
"db_user": "postgres",
"db_password": "password"
}SQLite: sqlite+aiosqlite:///./atb_prices.db (default)
PostgreSQL: postgresql+asyncpg://user:pass@host:port/db
from database import init_db, save_products_to_db, get_all_products_with_prices
# Initialize tables
await init_db()
# Save products (UPSERT + price history)
await save_products_to_db(products_list)
# Query with price history
products = await get_all_products_with_prices()httpx— HTTP client with async supportbeautifulsoup4+lxml— HTML parsingfake-useragent— User-Agent rotationsqlalchemy— Async ORMaiosqlite— SQLite async driverasyncpg— PostgreSQL async driver
uv run python cli.py categories# Basic parsing
uv run python cli.py parse -c economy
# Save to database
uv run python cli.py parse -c economy --save-db
# Custom rate limiting (default: 0.3s)
uv run python cli.py parse -c economy --delay 0.5
# Fast mode (higher risk of blocking)
uv run python cli.py parse -c economy --delay 0.1 --save-db# Formatted output
uv run python cli.py search -q "молоко"
# JSON output
uv run python cli.py search -q "хліб" --json🔍 Парсинг категории: economy
✅ Парсинг завершен за 2.32 сек
📦 Найдено товаров: 187
💰 Средняя цена: 80.10 грн
💸 Мин: 9.90 грн | Макс: 591.90 грн
💾 Сохраняю в базу данных...
✅ Данные сохранены
Configurable delay between requests to avoid blocking:
- 0.1s - fast, higher risk
- 0.3s - default, balanced
- 0.5-1.0s - conservative, for large batches
- Only saves price history when price actually changes
- Bulk database operations (2 queries instead of N×2)
- Reduces storage and improves performance
- Bulk product fetch in single query
- Bulk price history fetch with grouping
- UPSERT logic for products
- Price change detection before insert
✅ Category parser (sync/async)
✅ Product search
✅ Database storage (SQLite/PostgreSQL)
✅ Price history tracking
✅ CLI interface
✅ Rate limiting
✅ Bulk database operations
✅ Price change detection
MIT