🧪 Тест Sitemap (исправленная версия)

Информация о сервере:

Тест 1: Получаем sitemap.xml

URL: https://samaraspectehnika.ru/sitemap.xml

✅ HTTP 200 OK

Размер ответа: 588 байт

Первые байты (hex): 3c3f

Ответ не в формате gzip

Содержимое (первые 1000 символов):

<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

                <sitemap>
                    <loc>https://samaraspectehnika.ru/sitemap_storage__firms__28__26__26781__sitemap1.xml.gz</loc>
                    <lastmod>2026-01-14T19:21:04+02:00</lastmod>
                </sitemap>

                <sitemap>
                    <loc>https://samaraspectehnika.ru/sitemap_storage__firms__28__26__26781__sitemap2.xml.gz</loc>
                    <lastmod>2026-01-14T19:21:04+02:00</lastmod>
                </sitemap>
</sitemapindex>

📋 Простой рабочий парсер:

<?php
class SimpleSitemapParser {
    private $baseUrl = 'https://samaraspectehnika.ru';
    
    public function getSitemapContent($url) {
        $ch = curl_init($url);
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_TIMEOUT => 10,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_USERAGENT => 'Mozilla/5.0',
            CURLOPT_ENCODING => '' // важно для gzip
        ]);
        $content = curl_exec($ch);
        curl_close($ch);
        
        // Распаковываем gzip если нужно
        if (substr($content, 0, 2) == "\x1f\x8b" && function_exists('gzdecode')) {
            $content = @gzdecode($content);
        }
        
        return $content;
    }
    
    public function getAllProductUrls($limit = 100) {
        // 1. Получаем основной sitemap
        $sitemap = $this->getSitemapContent($this->baseUrl . '/sitemap.xml');
        
        // 2. Ищем файлы sitemap
        preg_match_all('/https:\/\/samaraspectehnika\.ru\/sitemap_storage__[^"\s]+\.xml\.gz/i', $sitemap, $matches);
        
        $allUrls = [];
        foreach ($matches[0] as $sitemapFile) {
            // 3. Получаем каждый файл
            $fileContent = $this->getSitemapContent($sitemapFile);
            
            // 4. Ищем товары
            preg_match_all('/https:\/\/samaraspectehnika\.ru\/p\/[^"\s]+/i', $fileContent, $productMatches);
            $allUrls = array_merge($allUrls, $productMatches[0]);
            
            if (count($allUrls) >= $limit) break;
        }
        
        return array_slice(array_unique($allUrls), 0, $limit);
    }
}
?>

🎯 Следующие шаги:

  1. Если все тесты пройдены ✅ - можно создавать полноценный парсер
  2. Sitemap содержит ВСЕ товары сайта
  3. Парсинг через sitemap надежнее чем через страницы категорий

🚀 Запустить полный парсинг через Sitemap