diff --git a/backend/main.py b/backend/main.py index d69bf51..8c21a4d 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1694,7 +1694,10 @@ async def create_report( # This is a leaf — return itself cat = tree_by_id.get(parent_id) if cat: - path_model = (cat.get("url") or "").lstrip("/") or None + # Trendyol pathModel formati: "-x-c" (or. yuz-kremi-x-c1122). + # Salt slug gonderilirse API 0 urun donuyor. queue_worker.py ile ayni mantik. + url_slug = (cat.get("url") or "").lstrip("/") + path_model = f"{url_slug}-x-c{cat['id']}" if url_slug else None return [(path_model, cat["name"], cat["id"])] return [] leaves = [] diff --git a/backend/scraper.py b/backend/scraper.py index 6e7801e..bbc2abc 100644 --- a/backend/scraper.py +++ b/backend/scraper.py @@ -186,6 +186,12 @@ class TrendyolSearchScraper: "pathModel": self.path_model, "pi": page, "ps": self.page_size, + # sst=BEST_SELLER: Trendyol'un cok satan siralamasi. Siralama parametresi + # verilmezse API sayfalar arasi tutarsiz sonuc donuyor — ayni urun farkli + # sayfalarda tekrar ediyor (240 urunluk cekimde ~%44 tekrar olctuk). + "sst": "BEST_SELLER", + # countryCode zorunlu oldu; yoksa API 400 "Required country information" doner + "countryCode": "TR", "channelId": 1, "storefrontId": 1, "culture": "tr-TR" @@ -264,7 +270,10 @@ def _normalize_search_product(raw: dict) -> dict: "imageUrl": raw.get("image", raw.get("imageUrl", "")), "merchantListings": raw.get("merchantListings", []), "winnerVariant": raw.get("winnerVariant", {}), - "socialProofs": raw.get("socialProofs", []), + # Search API alani TEKIL "socialProof" — cogul "socialProofs" diye okundugu icin + # bugune kadar hep bos donuyordu. Ic format cogul kaliyor (downstream kod ona bagli). + # Icerik: [{"key":"orderCount","value":"3000+"},{"key":"favoriteCount","value":"2M"}] + "socialProofs": raw.get("socialProof") or raw.get("socialProofs") or [], "categoryId": raw.get("categoryId"), "categoryName": raw.get("categoryName"), }