Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'vendor/autoload.php';
- $baseUrl = 'http://era-climata.ru/catalog/kondicionery.html?page=';
- $pagesCount = 1; //Измените меня на 23, когда нужно будет пройтись по всем страницам в каталоге
- set_time_limit(0);
- for ($i = 1; $i <= $pagesCount; $i++) {
- $url = $baseUrl . $i;
- $page = new \DiDom\Document($url, true);
- foreach ($page->find('.product_detail a') as $item) {
- $item = new \DiDom\Document('http://era-climata.ru' . $item->attr('href'), true);
- $image = $item->first('#image_big')->attr('src');
- $ext = array_pop(explode('.', $image));
- $path = '/images/' . md5($image) . '.' . $ext;
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . $path, file_get_contents('http://era-climata.ru' . $image));
- $image = $path; // Путь к скачанной картинке
- $name = $item->first('.product_name')->text(); //Название
- $price = $item->first('.money')->text(); // Цена
- $vendor = $item->first('.product_vendor a')->text(); //Производитель
- $description = $item->first('.tab-pane-content')->html(); // Описание
- $features = $item->first('.features-container')->html(); // Характеристики
- echo $name . ' - ' . $price . ' - ' . $vendor . '<br>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement