]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Очистка
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 4 Sep 2025 07:09:14 +0000 (10:09 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 4 Sep 2025 07:09:14 +0000 (10:09 +0300)
erp24/commands/MarketplaceController.php

index 65b788020bd392ccb9e710f9ebf50139dbda35b3..1c337ce1fe069aacccba9c0c02c0b453586c48d9 100644 (file)
@@ -204,126 +204,4 @@ class MarketplaceController extends Controller
         }
         return ExitCode::OK;
     }
-
-
-    public function actionParseFlowwow()
-    {
-        {
-            $this->stdout("Начинаем парсинг Flowwow..." . PHP_EOL);
-
-            // URL для парсинга
-            $baseUrl = 'https://flowwow.com/shop/baza-cvetov-24f-6167/';
-
-            $this->stdout("Загружаем основную страницу: {$baseUrl}" . PHP_EOL);
-
-            // Контекст для обхода SSL
-            $context = stream_context_create([
-                "ssl" => [
-                    "verify_peer" => false,
-                    "verify_peer_name" => false,
-                ],
-                "http" => [
-                    "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
-                    "timeout" => 30
-                ]
-            ]);
-
-            try {
-                // Загружаем основную страницу
-                $dom = HtmlDomParser::file_get_html($baseUrl, false, $context);
-
-                $categoryWrappers = $dom->findMulti('div.category-wrapper') ?? [];
-                $categoryCount = count($categoryWrappers);
-
-                foreach ($categoryWrappers as $index => $category) {
-                    $categoryNameElement = $category->findOne('h2.category-name');
-                    $categoryName = $categoryNameElement ? trim((string)$categoryNameElement->text()) : 'Без категории';
-
-                    $productCards = $category->findMulti('div.category-content-item a.product-card') ?? [];
-                    $productCount = count($productCards);
-
-                    foreach ($productCards as $productIndex => $card) {
-                        $productPath = $card->getAttribute('href') ?: null;
-                        if (!$productPath) { continue; }
-
-                        $productUrl = 'https://flowwow.com' . $productPath;
-
-                        $nameElement  = $card->findOne('div.name');
-                        $priceElement = $card->findOne('div.price span');
-                        $imgElement   = $card->findOne('img');
-
-                        $productName = $nameElement ? trim((string)$nameElement->text()) : '';
-                        $priceText   = $priceElement ? trim((string)$priceElement->text()) : '';
-                        $price       = (int)preg_replace('/[^\d]/u', '', $priceText);
-                        $imageUrl    = $imgElement ? (string)$imgElement->getAttribute('src') : '';
-
-                        $productData = [
-                            'category' => $categoryName,
-                            'name' => $productName,
-                            'price' => $price,
-                            'image_url' => $imageUrl,
-                            'product_url' => $productUrl
-                        ];
-
-                        try {
-                            $this->stdout("Загружаем страницу товара..." . PHP_EOL);
-
-                            // Загружаем страницу товара
-                            $productDom = HtmlDomParser::file_get_html($productUrl, false, $context);
-                            if ($productDom !== false) {
-                                $this->stdout("Страница товара загружена, извлекаем данные..." . PHP_EOL);
-
-                                // Извлечение описания
-                                $descriptionElement = $productDom->findOne('div.product-card-content');
-                                if ($descriptionElement) {
-                                    $productData['description'] = trim((string)$descriptionElement->text());
-                                }
-
-                                $properties = [];
-                                foreach ($productDom->findMulti('div.property-item') ?? [] as $item) {
-                                    $propName  = $item->findOne('div.property-name')?->text();
-                                    $propValue = $item->findOne('div.property-value')?->text();
-                                    if ($propName !== null && $propValue !== null) {
-                                        $properties[trim((string)$propName)] = trim((string)$propValue);
-                                    }
-                                }
-                                $productData['properties'] = $properties;
-
-                                $this->stdout("Характеристики извлечены: " . count($properties) . " свойств" . PHP_EOL);
-
-                               // $productDom->close();
-                            }
-                        } catch (\Exception $e) {
-                            $this->stdout("Ошибка при загрузке страницы товара: " . $e->getMessage() . PHP_EOL);
-                            $productData['error'] = 'Не удалось загрузить страницу товара: ' . $e->getMessage();
-                        }
-
-                        $products[] = $productData;
-                        $this->stdout("Товар добавлен в результат: {$productName}" . PHP_EOL);
-
-                        // Задержка между запросами
-                        $delay = 500000; // 0.5 секунды
-                        $this->stdout("Ждем {$delay} микросекунд перед следующим запросом..." . PHP_EOL);
-                        usleep($delay);
-                    }
-                }
-
-               // $dom->close();
-
-                $this->stdout("Парсинг завершен. Обработано товаров: " . count($products) . PHP_EOL);
-
-                // Сохраняем результат в файл (опционально)
-                $filename = date('Y-m-d_H-i-s') . '_flowwow_products.json';
-                file_put_contents($filename, json_encode($products, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-                $this->stdout("Результат сохранен в файл: {$filename}" . PHP_EOL);
-
-                return ExitCode::OK;
-
-            } catch (\Exception $e) {
-                $this->stdout("Произошла ошибка: " . $e->getMessage() . PHP_EOL);
-                return ExitCode::SOFTWARE;
-            }
-        }
-    }
-
-}
\ No newline at end of file
+}