简体   繁体   中英

SimpleHTMLDOM finding a div with class

I am an inexperienced programmer with DOM. I need to find out a div to remove it and all the content inside it. I have written the following code to get the div with class "name page_footer_container" . When I m trying to output the finding to test if all is fine, I get following error.

__________________Code_________________________________________

         require_once('simple_html_dom.php');
          $html = file_get_html($url);

           $element=$html->find('div[class=page_footer_container]');
            echo $element->outertext;

I get the following message with no result : Notice: Trying to get property of non-object.

Would you please let me know what is the problem and what is the best strategy to remove a div with all of its content.

This section of the page I want to remove :

 <div class="page_footer_container" >
       <div class="page_footer_content">
         <div class="page_footer_liner" ><hr class="page_footer_divider_above">
           <div       class="page_footer_text" ><a href="url">Click here to read our privacy policy.
                   <br>
                        Copyright © 2009-2012 mysite INc</a></div></div>        
           </div><div class="powered_by" >
                       <p><a rel="nofollow" href="#" target="_blank">
                             <img src="" border="0" alt=""></a><br><a rel="nofollow" href="" target="_blank"><strong>KKK</strong></a></p>
    </div></div>

Thanks a lot

Try to get the div this way:

$element=$html->find('div.page_footer_container');

With simple_html_dom you can search for elements using . for class and # for id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM