/ Published in: Perl
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/perl -w use strict; use Getopt::Std; use LWP::Simple; use HTML::Parser; # # Grab all links from local or remote html file # perl html munging # # option -a (/ -r) grabs only absolute (/ relative) urls # get options and argument # my %opts; getopts('ar', \%opts); die "Usage: $0 [-a | -r] filename [| URL]\n" # get the page either from file or url # my $page; $page = get($arg) } else { close FH; } # set the parser and parse # my $parser = HTML::Parser->new( api_version => 3, start_h => [\&start,"tagname, attr"], ); my @links; sub start { my ($tag, $attr) = @_; } } $parser->parse($page); # output #