0

How can i get DIV that are inside ul and li like the below codes what shows, there is alot of DIV inside a single li what method should i use? there is codes i have used below but they fetch all li including those i don't need, need your thought how can i obtain example <div class="single-event__code"> from <li class="single-event live"> see below php and css codes

  <div class="app_content">
  <ul class="js-events-container">...</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>
    <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>

UPDATE With this below PHP codes i can fetch all objects that are outside unordered list/list item and they will be displayed on screen but if i change and fetch data that are inside unordered list/list example <div class="single-event__code"> item it will output nothing.

 <?php

$html = file_get_contents('https://www.mkekabet.com/sportsbook/SOCCER/');
$dom = new DOMDocument();
 $internalErrors = libxml_use_internal_errors(true);
 $dom->loadHTML($html);
 libxml_use_internal_errors($internalErrors);
 $xpath = new DOMXPath($dom);

 $codeList = $xpath->query('//div[@class="app_content"]');
   foreach ($codeList as $codeDiv){
    var_dump($codeDiv->textContent);

 }

Need your thoughts.

Ruckser
  • 47
  • 1
  • 9
  • Don't know the application you're using. but isn't `$a` an object representation of an html fragment? I would expect that you could `$a->find()`. Or, couldn't you just start your find a little deeper, ie, find("div.single-event__code"). – Tim Morton Jun 17 '17 at 21:50
  • Let me try that. – Ruckser Jun 17 '17 at 23:26
  • these are css/jquery questions. Leave out the Php code and tag these questions with css and jquery and you will get a much better response. – pguardiario Jun 18 '17 at 22:32
  • It didn't work. @TimMorton – Ruckser Jun 19 '17 at 00:06
  • Can you give me a valid example if you will not care they really confuse me :-( @pguardiario – Ruckser Jun 19 '17 at 00:07
  • Read some css docs. Then read some jquery docs. – pguardiario Jun 19 '17 at 01:48
  • Ok thanks @pguardiario – Ruckser Jun 19 '17 at 06:40
  • @pguardiario Need your help brother :-(, my head got stuck i tried to pass through those css you mentioned and jquery my head is really confused, please share with your idea of css and jquery with example how should it be implemented with example, all the codes that i have tried recently they run with no error but they don't output anything – Ruckser Jun 19 '17 at 22:54

1 Answers1

0

You might want to use PHP DOM with xpath like in the example For selection, you can use "li.single-event .single-event__code". In this way you will get all the divs with the class "single-event__code" that are inside li elements.

Nasi Jofce
  • 132
  • 2
  • 10
  • I have tried to use xpath but with no lucky can you give me a simple example if you don't care. – Ruckser Jun 19 '17 at 00:05