Competitor Product Stock Availability Scraper Bot

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Competitor Product Stock Availability Scraper Bot
Medium
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Developing a Competitor Stock Availability Monitoring Bot

Monitoring competitor stock opens business opportunities: raise prices when competitors run out; signal managers about restocking; show "Limited Stock" when competitors are empty. The bot monitors availability on schedule and reacts to changes.

What Gets Tracked

  • Availability/absence — is the product for sale
  • Quantity — if site shows remaining stock ("3 left")
  • Status — in stock / preorder / discontinued / temporarily unavailable
  • Appearance dates — when product returned to sale

Stock Status Extractor

class StockStatusExtractor
{
    private array $inStockPatterns = ['/in\s*stock/i', '/available/i'];
    private array $outOfStockPatterns = ['/out\s*of\s*stock/i', '/unavailable/i', '/sold\s*out/i'];

    public function extract(string $html, array $config = []): StockStatus
    {
        $crawler = new Crawler($html);

        // Strategy 1: Microdata (most reliable)
        if ($availability = $this->extractFromMicrodata($crawler)) {
            return $availability;
        }

        // Strategy 2: JSON-LD
        if ($availability = $this->extractFromJsonLd($crawler)) {
            return $availability;
        }

        // Strategy 3: Custom CSS selectors from config
        if (!empty($config['stock_selector'])) {
            if ($availability = $this->extractWithSelector($crawler, $config)) {
                return $availability;
            }
        }

        // Strategy 4: Button state ("Buy" / "Add to Cart")
        return $this->extractFromButtonState($crawler);
    }

    public function extractQuantity(string $html): ?int
    {
        $crawler = new Crawler($html);
        $patterns = [
            '/(\d+)\s*(?:left|remaining)/i',
            '/in\s*stock[:\s]+(\d+)/i',
        ];

        $text = $crawler->text();
        foreach ($patterns as $pattern) {
            if (preg_match($pattern, $text, $m)) {
                return (int) $m[1];
            }
        }
        return null;
    }
}

Model and History

class CompetitorStock extends Model
{
    protected $casts = ['in_stock' => 'boolean'];

    protected static function booted(): void
    {
        static::updated(function (self $model) {
            if ($model->wasChanged('in_stock')) {
                CompetitorStockChanged::dispatch($model);
            }
        });
    }
}

Reacting to Changes

class HandleCompetitorStockChanged
{
    public function handle(CompetitorStockChanged $event): void
    {
        $stock = $event->stock;

        // Competitor ran out → notify about price opportunity
        if (!$stock->in_stock && $stock->getOriginal('in_stock')) {
            $this->notifyPriceOpportunity($stock->product, $stock->competitor);
        }

        // All competitors out of stock → apply scarcity pricing
        $allOutOfStock = CompetitorStock::where('product_id', $stock->product_id)
            ->where('in_stock', true)->doesntExist();

        if ($allOutOfStock && config('repricing.raise_when_competitors_out')) {
            $this->applyScarcityPricing($stock->product);
        }
    }
}

Development timeline: monitoring 3-5 competitors with history and events — 5-7 business days.