almeira-web/scripts/check_live_problem_titles.py

31 lines
1.1 KiB
Python

import urllib.request
import ssl
import json
import io
import sys
if sys.platform == 'win32':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
req = urllib.request.Request('https://drip-zone.online/api/products', headers={'User-Agent': 'Mozilla/5.0'})
try:
with urllib.request.urlopen(req, context=ctx, timeout=30) as resp:
data = json.loads(resp.read().decode('utf-8'))
products = data.get('products', [])
print(f'Total products: {len(products)}')
problem_titles = []
for p in products:
name = p.get('name', '')
name_l = name.lower()
if '.000' in name or any(w in name_l for w in ['36', '37', '38', '39', '40', '41', '42', '43', '44', '45', 'eur', 'talla']):
problem_titles.append((p.get('id', ''), name, p.get('brand', '')))
print(f'Found {len(problem_titles)} problem titles:')
for pid, t, b in problem_titles:
print(f' [{pid}] "{t}" (Brand: {b})')
except Exception as e:
print('Error:', e)