Фикс отсеивания по цене
This commit is contained in:
parent
1cf46ad9d2
commit
01a8c15b69
Binary file not shown.
@ -7,11 +7,15 @@ import re, json, math, logging, requests, os
|
||||
log = logging.getLogger("recorder")
|
||||
|
||||
# ─────────────────────── настройки ───────────────────────
|
||||
SEND_JSON = False # отправка POST
|
||||
SAVE_JSON = False # сохранять копию JSON
|
||||
SEND_JSON = False # отправка POST
|
||||
SAVE_JSON = True # сохранять копию JSON
|
||||
|
||||
POST_URL = "http://localhost:3005/parser/data"
|
||||
|
||||
MIN_PRICE = 40 # включительно
|
||||
MAX_PRICE = 1200 # включительно
|
||||
INVALID_CHARS = r'[<>:"/\\|*?]'
|
||||
|
||||
def sanitize_filename(name: str, repl: str = "_") -> str:
|
||||
"""Удаляет/заменяет символы, запрещённые в именах файлов."""
|
||||
clean = re.sub(INVALID_CHARS, repl, name)
|
||||
@ -57,6 +61,11 @@ class Recorder:
|
||||
weight_gram = float(row[idx["Свойство: Вес(г)"]]) if row[idx["Свойство: Вес(г)"]] else 0.0
|
||||
weight_kg = math.ceil(weight_gram / 1000) if weight_gram else 0
|
||||
|
||||
# --- фильтр по цене ---
|
||||
if not (MIN_PRICE <= price_int <= MAX_PRICE):
|
||||
# товар вне диапазона -> отправится только в .xlsx
|
||||
continue
|
||||
|
||||
# составляем объект
|
||||
variant = {
|
||||
"status_id": 1,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user