There is a certain $html variable obtained through curl (everything works). Next I want to get a div with the class partscontrol :

 $simpleHTML = new SimpleHTMLDOM; $div=$simpleHTML->str_get_html($html); $results=$div->find('.partscontrol'); 

but $results returns an empty array. If you just look for a <div> or <a> , etc., then everything works. What is the catch? Options such as ('.partscontrol',0) , ('div.partscontrol',0) , ('div.partscontrol') , ('div.partscontrol',0) - the same result.

  • $ results = $ div-> find ('. partscontrol'); - does not work at all ($ results returns an empty array), $ results = $ div-> find ('div') - everything is fine. What's the problem? Thanks. - Roma Tulaydan

1 answer 1

You need to point differently to what you are looking for in a class.

 $results=$div->find('div[class=partscontrol]'); 

or sometimes it might work

 $results=$div->find('div[class="partscontrol"]'); 
  • unfortunately and these options return the empty string - Roma Tulaydan
  • Are you sure that your $div is not empty? If curl gave you invalid html , then str_get_html() may not work. - cyadvert
  • I'm sure I checked it first. I’m talking if I’m just looking for a 'div', then everything is there, but if by the class, then the result is empty) - Roma Tulaydan
  • or invalid html you mean something else? - Roma Tulaydan