Hello all,
 
                Iam trying to use HTML::LinkExtor to extract img links from jsp files. But the issue here is that it is only extracting the links from the first file. It does not do it for all the other files attached. Is there anything wrong with this code? In this code iam getting all the links in file 2_1_4_4_growing_up.jsp. But not with 2_1_1_what_is.jsp and 2_1_1_cause.jsp. Please help
 
 use HTML::LinkExtor;
 
@files = qw(2_1_4_4_growing_up.jsp 2_1_1_what_is.jsp 2_1_1_cause.jsp);
$workarea = "c:\\perlscripts\\";
$home = "c:\\home";
 
$filelist = "$home/tmp/filelist";
    open (FILELIST, ">>$filelist");
  
   
    foreach my $file (@files)
    {
     my $p = HTML::LinkExtor->new(\&linkcallback);
   
       
            #$file =~ s|/|\\|g;
      next if (($file =~ m!templatedata!gsi) || ($file =~ m!documents!gsi));
            print FILELIST "$file\n";
      # adding all the images
      my @links = ();
    
      my $filepath = "$workarea" . "/" . "$file";
     # debug("$dbgInfo","document = '$filepath'\n");
      # print "## filename is ".$filename."\n";
 
     
      #my $p = HTML::LinkExtor->new();
      $p->parse_file($filepath);
 
      my @internal_links = ();
            for (my $i =0; $#links >= $i; ++$i) {
           
            print FILELIST "Iam here in links $i \n";
            # print "links[$i] is: ".$links[$i] . "\n";
                  if (($links[$i] =~ /http:/)||($links[$i] =~ /.js/) ||($links[$i] =~ /.jsp/)) {
                  } else {
                  # print FILELIST "$links[$i]\n";
                   push(@internal_links, $links[$i]);
                   
                   }
            }
 
      for (my $i=0; $#internal_links >= $i; ++$i) {
          #  debug("$dbgInfo","links = '$internal_links[$i]'\n");
            print FILELIST "$internal_links[$i]\n";
           
      }
       # return @internal_links;
 
      sub linkcallback {
      my ($tag, %attr) = @_;
      push(@links, values %attr);
      }
 
# adding all the images
    }
    close FILELIST;
Thxs,
 
 Mohammed Gazal.

Reply via email to