V
V
Vladimir2019-01-23 22:12:13
PHP
Vladimir, 2019-01-23 22:12:13

Can't get attribute value using simple HTML DOM?

Please help me get the value of the attribute, I can't figure out where my mistake is
5c48bc1290b6a204492192.jpeg

<?php
require_once 'simple_html_dom.php';
ini_set('memory_limit', '500M');

function getCurlResult ($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
  curl_setopt($ch, CURLPROTO_HTTPS,1);
  $htmltext = curl_exec($ch);
  curl_close($ch);
  //$htmltext = iconv("CP1251", "UTF-8", $htmltext);
  return $htmltext;
}

$zz = 0;

$urlYear = 'https://razmerkoles.ru/size/peugeot/308/2013/';

$html3 = str_get_html(getCurlResult($urlYear));			
$htmlArr3 = $html3->find('#vehicle-market-data .vehicle-market'); // массив внутренних рынков
if(count($htmlArr3) != 1) {// проверка есть ли разделения на внутренние рынки
  foreach ($htmlArr3 as $key => $div) {
  // echo $div->outertext . "<br>";
    $market = $html3->find('#vehicle-market-data .vehicle-market h4', $key)->plaintext; // выводит название внутреннего рынка
    echo $market . "<br>" . $urlYear . "<br>";
    foreach ($div->find('.modification-item') as $modifications) {
        $sizeBoltСipher = $modifications->find('tbody', 0)->attr['data-vehicle'];
          }
          
        }
        
      } else { //если нет разделения на внутренние рынки

      }

      $html3->clear(); // подчищаем за собой
      unset($html3);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question