fork download
  1. <?php
  2. $html = <<<HTML
  3. <div class="lstImv blackBd12">
  4.   <div class="stCl3 stLeft imvImg">
  5.   <div class="imgBox">
  6.   <a class="emp-imgs-link">
  7.   <span class="imgFrm frmBig frmLeft">
  8.   <img class="emp-img-principal">
  9.   </span>
  10.   <span class="imgFrm frmMd frmTop">
  11.   <img class="emp-img-logo">
  12.   </span>
  13.   <span class="imgFrm frmMd frmBot">
  14.   <img class="emp-img-foto">
  15.   </span>
  16.   </a>
  17.   </div>
  18.   <strong class="imvFse emp-fase">Get_text 1</strong>
  19.   </div>
  20.   <div class="imvInf stCl3 stRight">
  21.   <div class="infHd">
  22.   <div class="hdLeft stCl2">
  23.   <strong class="emp-nome infNme colorTxt"></strong>
  24.   <span class="emp-loc-part1 infLoc">Get_text 2</span>
  25.   <span class="emp-loc-part2 infLoc">Get_text 3</span>
  26.   </div>
  27.   <div class="hdRight stCl1">
  28.   <em class="emp-valor-apartir" >Get_text 4</em>
  29.   <strong class="emp-valor infVlr colorTxt">Get_text 5</strong>
  30.   </div>
  31.   </div>
  32.   <div class="infTxt">
  33.   <p class="blackTxt60 emp-descritivo"></p>
  34.   <ul>
  35.   <li class="txtBed emp-un-dorms">Get_text 6</li>
  36.   <li class="txtArea emp-un-area">Get_text 7</li>
  37.   <li class="txtToilet emp-un-bath">Get_text 8</li>
  38.   <li class="txtCar emp-un-park">Get_text 9</li>
  39.   </ul>
  40.   </div>
  41.   <div class="infBt">
  42.   <a href="/parceiro_cadastro" title="" class="btCadastrese stBt stBtLt colorBg whiteTxt rc9 sh15 emp-btn-cadastre">Get_text 10</a>
  43.   </div>
  44.   </div>
  45. </div>
  46. <div class="lstImv blackBd12">
  47.   <div class="stCl3 stLeft imvImg">
  48.   <div class="imgBox">
  49.   <a class="emp-imgs-link">
  50.   <span class="imgFrm frmBig frmLeft">
  51.   <img class="emp-img-principal">
  52.   </span>
  53.   <span class="imgFrm frmMd frmTop">
  54.   <img class="emp-img-logo">
  55.   </span>
  56.   <span class="imgFrm frmMd frmBot">
  57.   <img class="emp-img-foto">
  58.   </span>
  59.   </a>
  60.   </div>
  61.   <strong class="imvFse emp-fase">Other Get_text 1</strong>
  62.   </div>
  63.   <div class="imvInf stCl3 stRight">
  64.   <div class="infHd">
  65.   <div class="hdLeft stCl2">
  66.   <strong class="emp-nome infNme colorTxt"></strong>
  67.   <span class="emp-loc-part1 infLoc">Other Get_text 2</span>
  68.   <span class="emp-loc-part2 infLoc">Other Get_text 3</span>
  69.   </div>
  70.   <div class="hdRight stCl1">
  71.   <em class="emp-valor-apartir" >Other Get_text 4</em>
  72.   <strong class="emp-valor infVlr colorTxt">Other Get_text 5</strong>
  73.   </div>
  74.   </div>
  75.   <div class="infTxt">
  76.   <p class="blackTxt60 emp-descritivo"></p>
  77.   <ul>
  78.   <li class="txtBed emp-un-dorms">Other Get_text 6</li>
  79.   <li class="txtArea emp-un-area">Other Get_text 7</li>
  80.   <li class="txtToilet emp-un-bath">Other Get_text 8</li>
  81.   <li class="txtCar emp-un-park">Other Get_text 9</li>
  82.   </ul>
  83.   </div>
  84.   <div class="infBt">
  85.   <a href="/parceiro_cadastro" title="" class="btCadastrese stBt stBtLt colorBg whiteTxt rc9 sh15 emp-btn-cadastre">Other Get_text 10</a>
  86.   </div>
  87.   </div>
  88. </div>
  89. HTML;
  90.  
  91. $dom = new domDocument('1.0', 'utf-8');
  92. $dom->loadHTML($html);
  93. $dom->preserveWhiteSpace = false;
  94. $xpath = new DOMXPath($dom);
  95.  
  96.  
  97. $items = $xpath->query('//div[@class="lstImv blackBd12"]');
  98. for($i = 0; $i < $items->length; $i++)
  99. {
  100. $status = $xpath->query('//strong[@class="imvFse emp-fase"]');
  101. echo "Value :".$status->item($i)->nodeValue."\n";
  102.  
  103. $titulo = $xpath->query('//span[@class="emp-loc-part1 infLoc"]');
  104. echo "Value :".$titulo->item($i)->nodeValue."\n";
  105.  
  106. $titulo2 = $xpath->query('//span[@class="emp-loc-part2 infLoc"]');
  107. echo "Value :".$titulo2->item($i)->nodeValue."\n";
  108.  
  109. $valor = $xpath->query('//em[@class="emp-valor-apartir"]');
  110. echo "Value :".$valor->item($i)->nodeValue."\n";
  111.  
  112. $valor2 = $xpath->query('//strong[@class="emp-valor infVlr colorTxt"]');
  113. echo "Value :".$valor2->item($i)->nodeValue."\n";
  114.  
  115. $dorm = $xpath->query('//li[@class="txtBed emp-un-dorms"]');
  116. echo "Value :".$dorm->item($i)->nodeValue."\n";
  117.  
  118. $tam = $xpath->query('//li[@class="txtArea emp-un-area"]');
  119. echo "Value :".$tam->item($i)->nodeValue."\n";
  120.  
  121. }
  122. ?>
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Value		:Get_text 1
Value		:Get_text 2
Value		:Get_text 3
Value		:Get_text 4
Value		:Get_text 5
Value		:Get_text 6
Value		:Get_text 7
Value		:Other Get_text 1
Value		:Other Get_text 2
Value		:Other Get_text 3
Value		:Other Get_text 4
Value		:Other Get_text 5
Value		:Other Get_text 6
Value		:Other Get_text 7