Lagd i varukorgen
# Псевдокод для Scrapy def parse_price(self, response): # 1. Пробуем найти JSON-LD (схема Schema.org) json_data = response.xpath('//script[@type="application/ld+json"]/text()').get() if json_data: price = extract_price_from_json(json_data) # 2. Ищем стандартные CSS-классы if not price: price = response.css('.price-current__number::text').get()
Ключевые преимущества использования API
apiVersion: apps/v1 kind: Deployment metadata: name: price-api spec: replicas: 3 template: spec: containers: - name: api image: myregistry/price-parser:latest env: - name: REDIS_URL value: "redis://redis-service:6379" resources: limits: cpu: "1" memory: "1Gi"
from fastapi import FastAPI, BackgroundTasks, HTTPException from redis import Redis import json