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

  • SEARCH
  • Home
  • 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 8593651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:02:29+00:00 2026-06-12T00:02:29+00:00

Below is my data in html file. I want to find the values in

  • 0

Below is my data in html file. I want to find the values in the html file using “HTML::TreeBuilder”

<table id="stats" cellpadding="0" cellspacing="0">
<tbody>
    <tr class="row-even">
        <td class="stats_left">Main Domain</td>
        <td class="stats_right"><b>myabcab.com</b></td>
    </tr>
    <tr class="row-odd">
        <td class="stats_left">Home Directory</td>
        <td class="stats_right">/home/abc</td>
    </tr>
    <tr class="row-even">
        <td class="stats_left">Last login from</td>
        <td class="stats_right">22.32.232.223&nbsp;</td>
    </tr>
    <tr class="row-odd">
        <td class="stats_left">Disk Space Usage</td>
        <td class="stats_right">30.2 / &#8734; MB<br>
        <div class="stats_progress_bar">
        <div class="cpanel_widget_progress_bar" title="0%"
            style="position: relative; width: 100%; height: 100%; padding: 0px; margin: 0px; border: 0px">
        </div>
        <div class="cpanel_widget_progress_bar_percent" style="display: none">0</div>
        </div>
        </td>
    </tr>
    <tr class="row-even">
        <td class="stats_left">Monthly Bandwidth Transfer</td>
        <td class="stats_right">0 / &#8734; MB<br>
        <div class="stats_progress_bar">
        <div class="cpanel_widget_progress_bar" title="0%"
            style="position: relative; width: 100%; height: 100%; padding: 0px; margin: 0px; border: 0px">
        </div>
        <div class="cpanel_widget_progress_bar_percent" style="display: none">0</div>
        </div>
        </td>
    </tr>
</tbody>
  </table>

How can I find “Disk Usage space” value using “HTML::TreeBuilder”. I have many tds with same classes from above code,

  • 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-12T00:02:30+00:00Added an answer on June 12, 2026 at 12:02 am

    Find the <td> with the matching content, in this case “Disk Space Usage” and then find the next <td>.

    Once you have an element tree:

    my $usage = $t->look_down(
        _tag => 'td',
        sub {
            $_[0]->as_trimmed_text() =~ /^Disk Space Usage$/
        }
    )->right()->as_trimmed_text();
    

    You may want to wrap that in an eval block in case look_down doesn’t find a match.

    The tree navigation methods in HTML::Element are a key part of making effective use of HTML::TreeBuilder effectively.


    Mohini asks, “why doesn’t this work?”

    (formatting added by me)

    use strict;
    use warnings;
    use HTML::TreeBuilder;
    
    my $tree = HTML::TreeBuilder->new_from_file( "index.html");
    my $disk_value; my $disk_space;
    
    for ( $tree->look_down( _tag => q{tr}, 'class' => 'row-odd' ) ) {
    
        $disk_space = $tree->look_down(
             _tag => q{td},
             'class' => 'stats_left'
        )->as_trimmed_text;
    
        if ( $disk_space eq 'Home Directory' ) {
            $disk_value = $tree->look_down( _tag => q{td}, 'class' => 'stats_right' )
                               ->right()
                               ->as_trimmed_text();
        }
    
    }
    
    print STDERR "my home value is $disk_space : $disk_value\n";
    

    look_down starts from the root node you invoke it from, and looks down the element tree (these trees grow upside down) and returns either the list of matching nodes or the first matching node, depending on context.

    Since all calls to look down are on tree, you repeatedly find the same nodes each time through the loop.

    Your loop should look something more like this:

    my %table_stuff;
    
    for my $odd_row ( $tree->look_down( _tag => q{tr}, 'class' => 'row-odd' ) ) {
    
        $heading = $odd_row->look_down(
             _tag => q{td},
             'class' => 'stats_left'
        );
    
        $table_stuff{ $heading->as_trimmed_text() } = $heading->right()->as_trimmed_text();
    }
    

    This populates a hash with table elements.

    If you only want the one value, don’t use a loop at all. look_down already acts as a loop.

    my $heading = $t->look_down(
        _tag => 'td',
        sub {
            $_[0]->as_trimmed_text() =~ /^Home Directory$/
        }
    );
    
    my $value = $heading->right();
    
    #  Now $heading and $value have HTML::Element nodes that you can do whatever you want with.
    
    my $disk_value = $value->as_trimmed_text();
    my $disk_space = $heading->as_trimmed_text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to validate below data using regex and python. Below is the dump
below is my simple code using HTML 5 multiple file upload. All i need
I want to add some data which I get from user using html form
I want to find the size of an HTML file without HTTP headers and
is there a function in PHP that could parse the html data below to
i have data below from streaming: 'ID|20120206|080500|0000001|0|1|record1|END' 'ID|20120206|080500|0000002|0|1|record2|END' 'ID|20120206|080500|0000003|0|1|record3|END' and i want to process
Using the data frame below, I managed to compute a repeated-measures ANOVA for subject
I am parsing an XML file into a table and want to use the
I want to load a xml file using Jquery . The xml is generated
I am trying to parse a bit of data from an HTML file, but

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.