Upload app.py
Browse files
app.py
CHANGED
@@ -54,26 +54,36 @@ else:
|
|
54 |
products = []
|
55 |
if root is not None:
|
56 |
for item in root.findall('item'):
|
57 |
-
# Tüm ürünleri al, sonra stokta olma durumunu kontrol et
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
name = name_words[0]
|
60 |
full_name = ' '.join(name_words)
|
61 |
|
62 |
-
stock_amount = "stokta" if
|
63 |
|
64 |
# Stokta olmayan ürünler için fiyat/link bilgisi eklemiyoruz
|
65 |
if stock_amount == "stokta":
|
66 |
-
# Normal fiyat bilgisini al
|
67 |
-
|
|
|
68 |
|
69 |
-
# EFT fiyatını al (havale indirimli orijinal fiyat)
|
70 |
-
|
|
|
71 |
|
72 |
-
# İndirimli fiyatı al (kampanyalı fiyat)
|
73 |
-
|
|
|
74 |
|
75 |
-
# Havale indirimi fiyatını al (havale indirimli kampanyalı fiyat)
|
76 |
-
|
|
|
77 |
|
78 |
# Normal fiyatı yuvarla
|
79 |
try:
|
@@ -156,12 +166,14 @@ if root is not None:
|
|
156 |
else:
|
157 |
price_rebate_money_order = ""
|
158 |
|
159 |
-
# Ürün bilgilerini al
|
160 |
-
|
|
|
161 |
|
162 |
-
# Resim URL'si ekle (varsa)
|
163 |
-
|
164 |
-
|
|
|
165 |
else:
|
166 |
product_info.append("") # Boş resim URL'si
|
167 |
|
|
|
54 |
products = []
|
55 |
if root is not None:
|
56 |
for item in root.findall('item'):
|
57 |
+
# Tüm ürünleri al, sonra stokta olma durumunu kontrol et - None kontrolü
|
58 |
+
rootlabel_elem = item.find('rootlabel')
|
59 |
+
stock_elem = item.find('stockAmount')
|
60 |
+
|
61 |
+
if rootlabel_elem is None or stock_elem is None:
|
62 |
+
continue # Eksik veri varsa bu ürünü atla
|
63 |
+
|
64 |
+
name_words = rootlabel_elem.text.lower().split()
|
65 |
name = name_words[0]
|
66 |
full_name = ' '.join(name_words)
|
67 |
|
68 |
+
stock_amount = "stokta" if stock_elem.text and stock_elem.text > '0' else "stokta değil"
|
69 |
|
70 |
# Stokta olmayan ürünler için fiyat/link bilgisi eklemiyoruz
|
71 |
if stock_amount == "stokta":
|
72 |
+
# Normal fiyat bilgisini al - Güvenli versiyon
|
73 |
+
price_elem = item.find('priceTaxWithCur')
|
74 |
+
price_str = price_elem.text if price_elem is not None and price_elem.text else "Fiyat bilgisi yok"
|
75 |
|
76 |
+
# EFT fiyatını al (havale indirimli orijinal fiyat) - Güvenli versiyon
|
77 |
+
price_eft_elem = item.find('priceEft')
|
78 |
+
price_eft_str = price_eft_elem.text if price_eft_elem is not None and price_eft_elem.text else ""
|
79 |
|
80 |
+
# İndirimli fiyatı al (kampanyalı fiyat) - Güvenli versiyon
|
81 |
+
price_rebate_elem = item.find('priceRebateWithTax')
|
82 |
+
price_rebate_str = price_rebate_elem.text if price_rebate_elem is not None and price_rebate_elem.text else ""
|
83 |
|
84 |
+
# Havale indirimi fiyatını al (havale indirimli kampanyalı fiyat) - Güvenli versiyon
|
85 |
+
price_rebate_money_order_elem = item.find('priceRebateWithMoneyOrderWithTax')
|
86 |
+
price_rebate_money_order_str = price_rebate_money_order_elem.text if price_rebate_money_order_elem is not None and price_rebate_money_order_elem.text else ""
|
87 |
|
88 |
# Normal fiyatı yuvarla
|
89 |
try:
|
|
|
166 |
else:
|
167 |
price_rebate_money_order = ""
|
168 |
|
169 |
+
# Ürün bilgilerini al - None kontrolü ekle
|
170 |
+
product_url = item.find('productDetailUrl').text if item.find('productDetailUrl') is not None else ""
|
171 |
+
product_info = [stock_amount, price, product_url, price_eft, price_rebate, price_rebate_money_order]
|
172 |
|
173 |
+
# Resim URL'si ekle (varsa) - Güvenli versiyon
|
174 |
+
image_elem = item.find('imageHighResUrl')
|
175 |
+
if image_elem is not None and image_elem.text:
|
176 |
+
product_info.append(image_elem.text)
|
177 |
else:
|
178 |
product_info.append("") # Boş resim URL'si
|
179 |
|