Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

HTML::Tree look_down is not working

by Kanishka.black0 (Scribe)
on Jan 01, 2011 at 12:47 UTC ( #879988=perlquestion: print w/replies, xml ) Need Help??

Kanishka.black0 has asked for the wisdom of the Perl Monks concerning the following question:

use strict; use warnings; use YAML; use HTML::Tree; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $response = $ua->get(' +927'); my $content1 = $response->content; my $tree = HTML::Tree->new(); $tree->parse($content1); my $article = $tree->look_down(_tag=>'form',id=>'raaga'); my $table = $article->look_down(_tag=>'table',class=>'dataTbl',width=> +"450"); print Dump $table;
$table should be populate with a table .. but that;s not happening ...
my $table = $tree->look_down(_tag=>'table',class=>'dataTbl',width=>"450");
but if i try this way its getting the table .
$tree -- > HTML CODE
$article --> $tree ->look down a form with id
$table --> $article -> narrowing the tree with a table which has class
$table is not populate


$tree -- > HTML CODE
$table -->$tree-> narrowing the tree with a table which has class
Can any one tell me why isn't this working ???

Replies are listed 'Best First'.
Re: HTML::Tree look_down is not working
by wfsp (Abbot) on Jan 01, 2011 at 15:31 UTC
    Running your code the HTML in $article (cut down) looks like
    <form action="" id="raaga" method="get" name="raaga" onsubmit="return validate(this);" > <table align="center" border="0" cellpadding="1" cellspacing="2" height="100%" width="100%" > <tr> <!-- snipped --> </tr> </table> </form>
    There is one table but it doesn't have an id attribute. It has a width attribute of 100%. So your
    my $table = $article->look_down(_tag=>'table',class=>'dataTbl',width=> +"450");
    won't find anything ($table will be undef).

    There is a lot of javascript. When I point Firefox at that url the response does not contain a form with an id of raaga. What does the page look like when you log in?

    Give a bit more detail on what you are trying to do.

      i just want to sniff out the meta-data of that songs displayed ...

      As u mentioned u showed the first table ... but there are 3 tables actually
      data that i need is in the 3rd table ....

      thanks for reply .. its my mistake that i should have check with validate for html validation
      there are many mistakes in the webpage too

Re: HTML::Tree look_down is not working
by afoken (Chancellor) on Jan 01, 2011 at 13:00 UTC
    Can any one tell me why isn't this working ???

    Sure. Just tell us what is "not working". What goes in, what comes out, what do you expect to come out instead?


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      my $table = $article->look_down(_tag=>'table',class=>'dataTbl',width=>"450");
      on this statement String $table should be populated ... but its not happening

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://879988]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2023-04-01 10:40 GMT
Find Nodes?
    Voting Booth?

    No recent polls found