#!/usr/bin/perl
# Main purpose is to find and parse mp3 links from HTML page.
# Author: Vulcho Nedelchev
# Version: 1.0
# URL: http://www.vulcho.com/perl/mp3linkfinder.pl
# Modules: HTML::LinkExtractor, LWP::Simple
# Version: 1.1
# ------------------------------------------------------------
use HTML::LinkExtractor;
use LWP::Simple qw(get);
use strict;
my $base = shift;
my @extensions = qw(mp3 jpg gif html htm avi mpeg mpg asx m3u);
my $html = get($base);
my $LX = new HTML::LinkExtractor();
$LX->parse(\$html);
for my $Link ( @{$LX->links} ) {
# file name extensions extension:
for my $extension (@extensions) {
if ($Link->{href} =~ m|\.$extension$|i ) {
print $Link->{href} =~ /^http/ ? $Link->{href} : "$base".$Link->{href}, "\n";
}
}
}
undef $LX;
__END__
=head1 NAME
mp3linkfinder
It can be found @ http://www.vulcho.com/perl/mp3linkfinder/
=head1 DESCRIPTION
This script extracts links from HTML-code (usualy web page).
Argument is URL of page.
=head1 AUTHOR
Vulcho Nedelchev <kumcho@vulcho.com>
=head1 BUGS
Please report them.
=head1 SEE ALSO
HTML::LinkExtractor, LWP::Simple
=cut