Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

HTML::Tree look_down is not working

by Kanishka.black0 (Beadle)
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('http://www.raaga.com/channels/hindi/moviedetail.asp?mid=H002 +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

but

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

Comment on HTML::Tree look_down is not working
Download Code
Re: HTML::Tree look_down is not working
by afoken (Parson) 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?

    Alexander

    --
    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
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 w3.org validate for html validation
      there are many mistakes in the webpage too

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-12-22 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (121 votes), past polls