Good day! There is an html page filled with the following content:

 <a name="00:00:00" href="#00:00:00" class="ts">[00:00:00]</a> <span class="mn">&lt;Nick&gt;</span> " Шаблон " <br> 

Using simple_html_dom , you need to check the entire page and find a match with the filter.

 foreach($html->find('a.ts, span.mn, text') as $body => $value) { $iText = "Шаблон"; if (strpos($value, $iText) !== false) { echo "Find it."; echo $value."<br>Nick: "; echo $value->find('span')->plaintext."<br>"; } } 

This code example displays the found text by pattern. I need to capture in addition to the text also <span> with a nickname, and <а> with a date. I would be grateful for the hint how to do it right! Thank you very much!

  • Do such blocks on your page repeat? If yes, then do they have a parent. If so, then look for all the parents, and check the text inside the template. If suitable, then look for the desired content in the block. - teran
  • @teran, blocks are repeated, 90% of the entire page. There is no parent block, everything is in <body>. Therefore, there was such a question. That is, it turns out to separate the text separately, and already to link it with the previous ones, for example, tags - no. I will be glad to help and thank you! - Kate Gurman
  • then it’s probably easier to take the source code, and manually divide it into blocks. And then work with them later. - teran
  • @teran, that is, by the forces of this do not do it, huh? Parse yourself through the regular season? - Kate Gurman
  • You can try to search only for text , and when you find one that prev_sibling , then through prev_sibling you prev_sibling find the corresponding a and span . - teran

0