HTML::LinkChanger - abstract Perl class to change all linking URLs in HTML.
BEGIN {
package Http2Ftp; require HTML::LinkChanger; use vars qw(@ISA); @ISA = qw(HTML::LinkChanger); # # Converting http URLs to FTP urls # sub change_url { my $self = shift; my $url = shift; $url=~s/^http:/ftp:/; return $url; } }
my $http2ftp = new Http2Ftp();
my $converted_HTML = $http2ftp->filter($original_HTML);
HTML::LinkChanger is an abstract class so you need to subclass it to make it do something. See HTML::LinkChanger::Absolutizer for one useful example of such class.
HTML::LinkChanger uses HTML::Tagset::linkElements to change all attributes that contain links that needs to be updated.
This class is a subclass of HTML::Parser. You can call filter() method to convert scalar containing HTML or filter_file() method to convert HTML from file.
You can also call conventional HTML::Parser's parse() and parse_file() methods and call filtered_html() after that to retreive results.
Sergey Chernyshev <sergeyche@cpan.org>
HTML::Parser, HTML::Tagset, HTML::LinkChanger::Absolutizer
To install HTML::LinkChanger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::LinkChanger
CPAN shell
perl -MCPAN -e shell install HTML::LinkChanger
For more information on module installation, please visit the detailed CPAN module installation guide.