How can I parse HTML with Simple HTML DOM Parser

Home Forums Info & Off-Topic Discussion How can I parse HTML with Simple HTML DOM Parser

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #16430
    Luja
    Participant
    @lujashahd

    I have a site that I need to parse with Simple HTML DOM Parser that is something like this:

    <table class=”search-results”>
    <thead>…</thead>
    <tbody>
    <tr id=”ad-123123″>
    <td class=”thumbnail”>…</td>
    </tr>

    </tbody>
    </table>


    This is my code right now:

    include(‘./simple_html_dom.php’);

    $html = file_get_html(‘http://www.domain.com/subsite&#8217;);
    $searchResults = $html->find(‘table[@class=search-results’);

    foreach($searchResults->find(‘tr[@id^=ad-]’) as $tr) {

    }
    The difficult is that I catch this error right now:

    mod_fcgid: stderr: PHP Fatal error: Call to a member function find() on a non-object in /data/domains/mydomain/web/webroot/path/to/script.php on line 31
    $html is not null, I already debugged it. I get the same result if I use this code for the table finding:

    $searchResults = $html->find(‘.search-results’);

    What could be the problem? Is there any person  who can guide me in it!

    #16434
    Tassawer
    Participant
    @tassaweramin

    @lujashahd external references are not allowed.
    Please be careful.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.