mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-11 17:29:14 +02:00
- Created Amazon scraper service with advanced anti-bot techniques: * User-Agent rotation from realistic pool * Complete browser headers (Accept, Accept-Language, etc.) * Proxy rotation (10 residential proxies) * Random delays (1.5-4s) to mimic human behavior * Crawl4AI browser fingerprint randomization * NetworkIdle waiting for complete page load * Cookie acceptance automation - Added Amazon search API endpoint with SSE streaming * Real-time progress updates * Proper error handling * Health check endpoint - Created dedicated Amazon France frontend page: * Modern UI with product cards * Rating display (stars + review count) * Price formatting with discount badges * Prime badge support * Stock status indicators * Sponsored product labels * Direct Amazon links - Removed store list (ENSEIGNES_DATA cleared) * Migration from discount stores to Amazon France * Catalog system kept for future use - Updated navigation: * Added "Amazon France" menu item with ShoppingBag icon * Positioned between Search and Compare * Available on desktop and mobile Technical stack: - Backend: Crawl4AI + BeautifulSoup for scraping - Frontend: React + Shadcn UI components - API: FastAPI with SSE streaming
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
"""
|
|
Seed default enseignes (stores) for the catalog module
|
|
"""
|
|
|
|
import logging
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.models import Enseigne
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Liste des enseignes vidée - migration vers Amazon France uniquement
|
|
# Les magasins discount ne sont plus gérés via le système de catalogues
|
|
ENSEIGNES_DATA = []
|
|
|
|
|
|
def seed_enseignes(db: Session) -> int:
|
|
"""
|
|
Seed the default enseignes if they don't exist.
|
|
|
|
Returns:
|
|
Number of enseignes created
|
|
"""
|
|
created = 0
|
|
|
|
for data in ENSEIGNES_DATA:
|
|
# Check if enseigne already exists
|
|
existing = db.query(Enseigne).filter_by(slug_bonial=data["slug_bonial"]).first()
|
|
|
|
if not existing:
|
|
enseigne = Enseigne(**data)
|
|
db.add(enseigne)
|
|
created += 1
|
|
logger.info(f"Created enseigne: {data['nom']}")
|
|
else:
|
|
logger.debug(f"Enseigne already exists: {data['nom']}")
|
|
|
|
db.commit()
|
|
logger.info(f"Seeding complete: {created} enseigne(s) created")
|
|
|
|
return created
|
|
|
|
|
|
def get_enseigne_by_slug(db: Session, slug: str) -> Enseigne | None:
|
|
"""Get an enseigne by its Bonial slug"""
|
|
return db.query(Enseigne).filter_by(slug_bonial=slug).first()
|
|
|
|
|
|
def get_all_active_enseignes(db: Session) -> list[Enseigne]:
|
|
"""Get all active enseignes ordered by display order"""
|
|
return (
|
|
db.query(Enseigne)
|
|
.filter_by(is_active=True)
|
|
.order_by(Enseigne.ordre_affichage)
|
|
.all()
|
|
)
|