Update app.py
Browse files
app.py
CHANGED
@@ -77,78 +77,102 @@ for item in root.findall('item'):
|
|
77 |
|
78 |
# Havale indirimli orijinal fiyatı yuvarla (varsa)
|
79 |
if price_eft_str:
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
else:
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
price_rebate_money_order =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
# Sadece ürün linkini al, resim linkini alma
|
154 |
product_link = item.find('productLink').text if item.find('productLink') is not None else ""
|
|
|
77 |
|
78 |
# Havale indirimli orijinal fiyatı yuvarla (varsa)
|
79 |
if price_eft_str:
|
80 |
+
# Normal fiyatı yuvarla
|
81 |
+
try:
|
82 |
+
price_float = float(price_str)
|
83 |
+
# Fiyat 200000 üzerindeyse en yakın 5000'lik basamağa yuvarla
|
84 |
+
if price_float > 200000:
|
85 |
+
price = str(round(price_float / 5000) * 5000) # En yakın 5000'e yuvarla
|
86 |
+
# Fiyat 30000 üzerindeyse en yakın 1000'lik basamağa yuvarla
|
87 |
+
elif price_float > 30000:
|
88 |
+
price = str(round(price_float / 1000) * 1000) # En yakın 1000'e yuvarla
|
89 |
+
# Fiyat 10000 üzerindeyse en yakın 100'lük basamağa yuvarla
|
90 |
+
elif price_float > 10000:
|
91 |
+
price = str(round(price_float / 100) * 100) # En yakın 100'e yuvarla
|
92 |
+
# Diğer durumlarda en yakın 10'luk basamağa yuvarla
|
93 |
+
else:
|
94 |
+
price = str(round(price_float / 10) * 10) # En yakın 10'a yuvarla
|
95 |
+
except (ValueError, TypeError):
|
96 |
+
price = price_str # Sayıya dönüştürülemezse olduğu gibi bırak
|
97 |
+
|
98 |
+
# Havale indirimli orijinal fiyatı yuvarla (varsa)
|
99 |
+
if price_eft_str:
|
100 |
+
try:
|
101 |
+
price_eft_float = float(price_eft_str)
|
102 |
+
# Fiyat 200000 üzerindeyse en yakın 5000'lik basamağa yuvarla
|
103 |
+
if price_eft_float > 200000:
|
104 |
+
price_eft = str(round(price_eft_float / 5000) * 5000)
|
105 |
+
# Fiyat 30000 üzerindeyse en yakın 1000'lik basamağa yuvarla
|
106 |
+
elif price_eft_float > 30000:
|
107 |
+
price_eft = str(round(price_eft_float / 1000) * 1000)
|
108 |
+
# Fiyat 10000 üzerindeyse en yakın 100'lük basamağa yuvarla
|
109 |
+
elif price_eft_float > 10000:
|
110 |
+
price_eft = str(round(price_eft_float / 100) * 100)
|
111 |
+
# Diğer durumlarda en yakın 10'luk basamağa yuvarla
|
112 |
else:
|
113 |
+
price_eft = str(round(price_eft_float / 10) * 10)
|
114 |
+
except (ValueError, TypeError):
|
115 |
+
price_eft = price_eft_str
|
116 |
+
else:
|
117 |
+
# Havale indirimli fiyat verilmemişse, orijinal fiyattan %2.5 indirim hesapla
|
118 |
+
try:
|
119 |
+
price_eft_float = price_float * 0.975 # %2.5 indirim
|
120 |
+
# Fiyat 200000 üzerindeyse en yakın 5000'lik basamağa yuvarla
|
121 |
+
if price_eft_float > 200000:
|
122 |
+
price_eft = str(round(price_eft_float / 5000) * 5000)
|
123 |
+
# Fiyat 30000 üzerindeyse en yakın 1000'lik basamağa yuvarla
|
124 |
+
elif price_eft_float > 30000:
|
125 |
+
price_eft = str(round(price_eft_float / 1000) * 1000)
|
126 |
+
# Fiyat 10000 üzerindeyse en yakın 100'lük basamağa yuvarla
|
127 |
+
elif price_eft_float > 10000:
|
128 |
+
price_eft = str(round(price_eft_float / 100) * 100)
|
129 |
+
# Diğer durumlarda en yakın 10'luk basamağa yuvarla
|
130 |
+
else:
|
131 |
+
price_eft = str(round(price_eft_float / 10) * 10)
|
132 |
+
except (ValueError, TypeError):
|
133 |
+
price_eft = ""
|
134 |
+
|
135 |
+
# İndirimli fiyatı yuvarla
|
136 |
+
try:
|
137 |
+
if price_rebate_str:
|
138 |
+
price_rebate_float = float(price_rebate_str)
|
139 |
+
# Fiyat 200000 üzerindeyse en yakın 5000'lik basamağa yuvarla
|
140 |
+
if price_rebate_float > 200000:
|
141 |
+
price_rebate = str(round(price_rebate_float / 5000) * 5000)
|
142 |
+
# Fiyat 30000 üzerindeyse en yakın 1000'lik basamağa yuvarla
|
143 |
+
elif price_rebate_float > 30000:
|
144 |
+
price_rebate = str(round(price_rebate_float / 1000) * 1000)
|
145 |
+
# Fiyat 10000 üzerindeyse en yakın 100'lük basamağa yuvarla
|
146 |
+
elif price_rebate_float > 10000:
|
147 |
+
price_rebate = str(round(price_rebate_float / 100) * 100)
|
148 |
+
# Diğer durumlarda en yakın 10'luk basamağa yuvarla
|
149 |
+
else:
|
150 |
+
price_rebate = str(round(price_rebate_float / 10) * 10)
|
151 |
+
else:
|
152 |
+
price_rebate = ""
|
153 |
+
except (ValueError, TypeError):
|
154 |
+
price_rebate = price_rebate_str
|
155 |
+
|
156 |
+
# Havale indirimi kampanyalı fiyatı yuvarla
|
157 |
+
try:
|
158 |
+
if price_rebate_money_order_str:
|
159 |
+
price_rebate_money_order_float = float(price_rebate_money_order_str)
|
160 |
+
# Fiyat 200000 üzerindeyse en yakın 5000'lik basamağa yuvarla
|
161 |
+
if price_rebate_money_order_float > 200000:
|
162 |
+
price_rebate_money_order = str(round(price_rebate_money_order_float / 5000) * 5000)
|
163 |
+
# Fiyat 30000 üzerindeyse en yakın 1000'lik basamağa yuvarla
|
164 |
+
elif price_rebate_money_order_float > 30000:
|
165 |
+
price_rebate_money_order = str(round(price_rebate_money_order_float / 1000) * 1000)
|
166 |
+
# Fiyat 10000 üzerindeyse en yakın 100'lük basamağa yuvarla
|
167 |
+
elif price_rebate_money_order_float > 10000:
|
168 |
+
price_rebate_money_order = str(round(price_rebate_money_order_float / 100) * 100)
|
169 |
+
# Diğer durumlarda en yakın 10'luk basamağa yuvarla
|
170 |
+
else:
|
171 |
+
price_rebate_money_order = str(round(price_rebate_money_order_float / 10) * 10)
|
172 |
+
else:
|
173 |
+
price_rebate_money_order = ""
|
174 |
+
except (ValueError, TypeError):
|
175 |
+
price_rebate_money_order = price_rebate_money_order_str
|
176 |
|
177 |
# Sadece ürün linkini al, resim linkini alma
|
178 |
product_link = item.find('productLink').text if item.find('productLink') is not None else ""
|