|
| Hi All,
I am a beginner in Perl. I am trying to extract the content between
the <form>,</form> tags. My code seems to be correct, somehow I am
unable to trace where it's going wrong??
#!/usr/local/bin/perl
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTML::TreeBuilder;
$mystring="http://www.google.com/";
$contents=get($mystring);
my $form1 = get_heading($contents);
print $form1;
sub get_heading {
my $tree = HTML::TreeBuilder->new;
$tree->parse_file($_[0]);
my $formcontent;
my $form = $tree->look_down('_tag', 'form');
print $form; ## Does'nt print form
if($form) {
$formcontent = $form->as_text;
} else {
warn "No form found";
}
$tree->delete;
return $formcontent;
}
The above code just prints the warning message i.e., "No form found"
though the input URL has a form in it...
Please input ur suggestions...
thanks in advance
|
|