Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:54:49+00:00 2026-06-13T10:54:49+00:00

Simple HTML DOM is basically a php you add to your pages which lets

  • 0

Simple HTML DOM is basically a php you add to your pages which lets you have simple web scraping. It’s good for the most part but I can’t figure out the manual as I’m not much of a coder. Are there any sites/guides out there that have any easier help for this? (the one at php.net is a bit too complicated for me at the moment) Is there a better place to ask this kind of question?

The site for it is at: http://simplehtmldom.sourceforge.net/manual.htm

I can scrape stuff that has specific classes like <tr class="group">, but not for stuff that’s in between. For example.. This is what I currently use…

$url = 'http://www.test.com';
$html = file_get_html($url);
foreach($html->find('tr[class=group]') as $result)
  {
    $first = $result->find('td[class=category1]',0);
    $second = $result->find('td[class=category2]',0);
    echo $first.$second;
  }
}

But here is the kind of code I’m trying to scrape.

<table>
  <tr class="Group">
    <td>
      <dl class="Summary">
        <dt>Heading 1</dt>
          <dd><a href="#123" class="ViewProfile">Cat</a></dd>
          <dd><a href="#032" class="ViewProfile">Bacon</a></dd>
        <dt>Heading 2</dt>
          <dd><a href="#143" class="ViewProfile">Narwhal</a></dd>
          <dd><a href="#642" class="ViewProfile">Ice Soap</a></dd>
      </dl>
    </td>
  </tr>
</table>

I’m trying to extract the content of each <dt> and put it to a variable. Then I’m trying to extract the content of each <dd> and put it to a variable, but nothing I tried works. Here’s the best I could find, but it gives me back only the first heading repeatedly rather than going to the second.

foreach($html->find('tr[class=Summary]') as $result2)
  {
    echo $result2->find('dt',0)->innertext;
  }

Thanks to anyone who can help. Sorry if this is not clear or that it’s so long. Ideally I’d like to be able to understand these DOM commands more as I’d like to figure this out myself rather than someone here just do it (but I’d appreciate either).

TL;DR: I am trying to understand how to use the commands listed in the manual (url above). The ‘manual’ isn’t easy enough. How do you go about learning this stuff?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:54:50+00:00Added an answer on June 13, 2026 at 10:54 am

    I think $result2->find('dt',0) gives you back element 0, which is the first. If you omit that, you should be able to get an array (or nodelist) instead. Something like this:

    foreach($html->find('tr[class=Summary]') as $result2)
    {
        foreach ($result2->find('dt') as $node)
        {
           echo $node->innertext;
        }
    }
    

    You don’t strictly need the outer for loop, since there’s only 1 tr in your document. You could even leave it altogether to find each dt in the document, but for tools like this, I think it’s a good thing to be both flexible and strict, so you are prepared for multiple rows, but don’t accidentally parse dts from anywhere in the document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning scraping using the PHP Simple HTML DOM Parser and Xpath. Accroding
I have translated the PHP Simple HTML DOM query: $article->find('td[id$=tdDescription] div a', 1)->plaintext; to
which one is better for screen scraping? simple html dom or snoopy ?? i
I have the Simple HTML DOM Parser for PHP, and I am using the
I'm using PHP Simple HTML DOM Parser And I have some HTML codes that
I am using PHP Simple HTML DOM Parser and it is consuming a lot
Here is example which I have try <?php include 'spider/classes/simple_html_dom.php'; $html = new simple_html_dom();
I'm using 'Simple HTML Dom' to scrape the HN Front Page (news.ycombinator.com), which works
Using PHP Simple HTML DOM Parse but unable to get images to display. I
I want to use the PHP Simple HTML DOM Parser to display all my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.