NAME
Web::Compare - Compare web pages
SYNOPSIS
DESCRIPTION
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(
{
hook_before
=>
sub
{
my
(
$self
,
$req
) =
@_
;
if
(
$req
->uri =~ /staging\./) {
$req
->authorization_basic(
'id'
,
'password'
);
}
},
}
);
warn
$wc
->report;
METHODS
new($left_url, $right_url[, $options_ref])
constractor
$left_url
and $right_url
is the URL or these should be HTTP::Request object.
$options_ref
follows bellow params.
- ua
-
The user agent object what you want.
- hook_before
- hook_after
-
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
;
},
},
);
- on_error
-
When a request was failed,
on_error
callback is invoked if you set this option as code ref.use
Web::Compare;
use
Data::Dumper;
my
$wc
= Web::Compare->new(
$lefturl
,
$righturl
, {
on_error
=>
sub
{
my
(
$self
,
$res
,
$req
) =
@_
;
warn
Dumper(
$req
,
$res
);
},
},
);
- diff
-
By default,
Web::Compare
uses Diff::LibXDiff for reporting diff. If you want to use an other diff tool, you'll setdiff
param as code ref.use
Web::Compare;
my
$wc
= Web::Compare->new(
$lefturl
,
$righturl
, {
diff
=>
sub
{
my
(
$left
,
$right
) =
@_
;
String::Diff::diff_merge(
$left
,
$right
);
},
},
);
report
Send requests and report diff
REPOSITORY
Web::Compare is hosted on github: http://github.com/bayashi/Web-Compare
Welcome your patches and issues :D
AUTHOR
Dai Okabayashi <bayashi@cpan.org>
SEE ALSO
LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.