Web::Compare - Compare web pages
use Web::Compare; my $wc = Web::Compare->new($left_url, $right_url); warn $wc->report;
Web::Compare is the tool for comparing web pages.
It might be useful for comparing staging web page to production web page like below.
use Web::Compare; my $wc = Web::Compare->new( 'http://staging.example.com/foo/bar', 'http://production.example.com/foo/bar', { hook_before => sub { my ($self, $req) = @_; if ($req->uri =~ /staging\./) { $req->authorization_basic('id', 'password'); } }, } ); warn $wc->report;
constractor
$left_url and $right_url is the URL or these should be HTTP::Request object.
$left_url
$right_url
$options_ref follows bellow params.
$options_ref
The user agent object what you want.
There are hooks around the request.
use Web::Compare; my $wc = Web::Compare->new( $lefturl, $righturl, { hook_before => sub { my ($self, $req) = @_; $req->header('X-foo' => 'baz'); }, hook_after => sub { my ($self, $res, $req) = @_; (my $content = $res->content) =~ s!Hello!Hi!; return $content; }, }, );
When a request was failed, on_error callback is invoked if you set this option as code ref.
on_error
use Web::Compare; use Data::Dumper; my $wc = Web::Compare->new( $lefturl, $righturl, { on_error => sub { my ($self, $res, $req) = @_; warn Dumper($req, $res); }, }, );
By default, Web::Compare uses Diff::LibXDiff for reporting diff. If you want to use an other diff tool, you'll set diff param as code ref.
Web::Compare
diff
use Web::Compare; use String::Diff qw//; my $wc = Web::Compare->new( $lefturl, $righturl, { diff => sub { my ($left, $right) = @_; String::Diff::diff_merge($left, $right); }, }, );
Send requests and report diff
Web::Compare is hosted on github: http://github.com/bayashi/Web-Compare
Welcome your patches and issues :D
Dai Okabayashi <bayashi@cpan.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Web::Compare, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::Compare
CPAN shell
perl -MCPAN -e shell install Web::Compare
For more information on module installation, please visit the detailed CPAN module installation guide.