Search code examples
phpweb-scrapingsimple-html-dom

Simple HTML DOM - Skip certain element


I want to ignore the contents of the <a> which is inside <h3> element and only get the text of the <h3>.

<h3>
144.000 TL
<a class="emlak-endeksi-link trackClick trackId_emlak-endeksi-link" id="emlakEndeksiLink">
Emlak Endeksi</a>
</h3>

Example: only want to get 144.000 TL and ignore the (Emlak Endeksi)

foreach ($html1->find('div.classifiedInfo h3') as $price) {
    $ilanlar['price'] = $price->plaintext;
}

Solution

  • not very familiar with simple html dom, but ... selecting the text node via http://simplehtmldom.sourceforge.net/manual.htm#frag_find_textcomment should help?

    $ilanlar['price'] = $price->find('text', 0)->plaintext;