我在哪里错误取出无序列表简单的html dom

时间:2017-06-22 22:25:57

标签: javascript php html css simple-html-dom

我正在尝试抓取<div class="single-event__code"><div class="single-event__time">&amp; <div class="single-event__players">使用以下PHP代码,如果我从<div class="app_content">打印数据,那么DIV内的所有数据都将被打印出来,但如果我改为上面提到的那些数据之一,我将不打印任何数据#39;知道我做错了在哪里我尝试了很多方法但问题仍然存在,我尝试使用DOM Document同样的事情发生,需要你的建议这让我发疯。

 <div class="app_content">
 <ul class="js-events-container">
 ::BEFORE
<li class="single-event live">...</li>
<li class="single-event live">...</li>
<li class="single-event live">...</li>
<li class="single-event live">...</li>
<li class="single-event live">
 ::before
 //First DIV of li
<div class="single-event__code">
Event Code: <strong>96441</strong>
           </div>
    <div class="single-event__time">
        <span class="score js-score">LIVE</span>
        <span class="time js-timer"></span>
        </div>
    <div class="single-event__players">
   <a href="/sportsbook/SOCCER/BRAZIL_SERIE_D/400953/">
    AA Portuguesa RJ <span> v </span> Audax SP </a>
             </div>
   <div class="single-event__bets three markets">
<div class="single-event__bets__container js-bets-container">
            <div class="single-event__bets__price">
                 1.02
                  </div><div class="single-event__bets__price">
                 81.00
                  </div><div class="single-event__bets__price">
                 101.00
                  </div></div>
             <div class="single-event__bets__more">
   <a href="/sportsbook/SOCCER/BRAZIL_SERIE_D/400953/" data-markets="+18">+
  <span>+18</span></a></div>
    </div>
   ::after
   </li>

<li class="single-event live">...</li>
<li class="single-event live">...</li>
<li class="single-event live">...</li>
<li class="single-event live">...</li>

   ::AFTER </ul>
</div>

PHP CODES

 <strong>STAFF AT TOP</strong>
  <?php
  include('advanced_html_dom.php'); 

  $html = file_get_html('https://www.mkekabet.com/sportsbook/SOCCER/');
   $table = $html->find('.app__content', 0);
   $links = $table->find('.js-events-container', 0);
   $table2 = $links->find('.single-event live', 0);
    $links2 = $table2->find('.single-event__code', 0);

   echo $links2;

1 个答案:

答案 0 :(得分:0)

对于初学者来说,你似乎有错误的选择器。

Toolbar

应该是

table2 = $links->find('.single-event live');

由于table2 = $links->find('.single-event.live'); single-event是同一元素的类。