Chitika

Monday, January 30, 2012

Perl get all HTML Ids

#!/usr/bin/perl

while (<STDIN>) {

        $p = $_;

        while ($p) {
                if($p =~ m/id=\s*\"(\w+)\"/g) {

                        print $1."\n";

                } else { last; }

                $p = $';
        }
}

Usage:

cat file.html | ./getIds.pl

No comments:

Post a Comment