mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-08-29 21:38:00 +00:00
fix(scraper): best seller siralamasi, tekrar eden urunler ve sosyal kanit bugu duzeltildi
Ne yaptik: - scraper.py fetch_page: "sst": "BEST_SELLER" parametresi eklendi - scraper.py fetch_page: "countryCode": "TR" parametresi eklendi - scraper.py _normalize_search_product: socialProof (TEKIL) alanindan okunuyor, eski cogul socialProofs fallback olarak birakildi - main.py _find_leaves: pathModel artik "<slug>-x-c<categoryId>" formatinda uretiliyor (queue_worker.py ile ayni mantik) Neden yaptik: - Trendyol Search API siralama parametresi verilmezse sayfalar arasi tutarsiz sonuc donuyordu: 240 urunluk cekimde sadece 134 benzersiz urun geliyordu, yani raporlarin %44'u ayni urunun tekrariydi. sst=BEST_SELLER ile tekrar tamamen sifirlandi (240/240 benzersiz) - Sosyal kanit alani API'de TEKIL "socialProof" olarak geliyor ama kod cogul "socialProofs" diye okuyordu; bu yuzden satis/favori verisi hep bos donuyordu. Telafi icin cagrilan Top Rankings API ise Trendyol tarafinda kaldirildigi icin 404 veriyor (K8s loglarinda dogrulandi). Duzeltmeden sonra 238/240 uruna orderCount ve favoriteCount geliyor - countryCode zorunlu hale gelmis; yoksa API 400 "Required country information" donuyor - main.py salt slug gonderiyordu (or. "yuz-kremi"), API 0 urun donuyordu. Dogru format "yuz-kremi-x-c1122" Test: - yuz-kremi-x-c1122, 10 sayfa: 240 urun / 240 benzersiz / 0 tekrar / 238 sosyal kanit - Regresyon: 6 farkli kategori tipinde 6/6 basarili, tekrar yok Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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: "<slug>-x-c<categoryId>" (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 = []
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user