Article 4VDBC perl : HTML::TokeParser::Simple

perl : HTML::TokeParser::Simple

by
//////
from LinuxQuestions.org on (#4VDBC)
Code:#!/usr/bin/perl -w
use strict;
use warnings;

use Term::ANSIColor qw(:constants);
use Term::ANSIColor;
use HTML::TokeParser::Simple;
use Getopt::Std;
##############################################################
use vars qw/ $opt_h $html $sitename $url $line @lines @attr /;
getopts('h');

if ($opt_h) {
print q/
perl lynxsniff.pl <sitename.com>
Prints page source with syntax highlight.

/;
exit(0);
};

$sitename = shift or die "Usage: $0 <sitename.com>\n";
$sitename = $ARGV[0];

open(FH, "/usr/bin/lynx -source $sitename|") or die "$!\n";

while (<FH>)
{

my $html = <FH>;
my $ignore=0;

my $p = HTML::TokeParser::Simple->new(string => $html);

while ( my $token = $p->get_token ) {
if ( $token->is_start_tag ) {
my $element = $token->[1];
my @attrs = @{$token->[3]};
print qq(<),colored($element,'magenta');
foreach my $attr ( @attrs ) {
if ( $attr ne '/' && $attr ne 'script' ) {
print qq( ),colored($attr, 'cyan');
if ( defined ( $token->[2]{$attr} ) ) {
print qq(="),colored($token->[2]{$attr},'green'),qq(");
}
} else {
print qq( $attr);
}
}
print qq(>);

} elsif ( $token->is_text ) {
print colored($token->[1],'white');

} elsif ( $token->is_end_tag ) {
print qq(</),colored( $token->[1],'magenta'),qq(>);

} elsif ( $token->is_comment ) {
print colored( $token->[1],'white');

} elsif ( $token->is_declaration ) {
print colored( $token->[1],'bright_white');

} else
{
#Everything excluding scripts falls here handle as appropriate
next unless $token->is_text;
print $token->as_is;
}
}
}
close FH;hello all.

how can i syntax highlight (red) Iframes using this script?
i have tried to find solution but no luck sofar.latest?d=yIl2AUoC8zA latest?i=HzTvJl0LGqM:ci_xSKWy_eY:F7zBnMy latest?i=HzTvJl0LGqM:ci_xSKWy_eY:V_sGLiP latest?d=qj6IDK7rITs latest?i=HzTvJl0LGqM:ci_xSKWy_eY:gIN9vFwHzTvJl0LGqM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments