NAME
WWW::Monitor - Monitor websites for updates and changes
VERSION
Version 0.01
SYNOPSIS
use MIME::Lite; use WWW::Monitor;
sub notify { my ($url,$text) =@_; foreach my $recipient ('user1@host','user2@host2') { my $mail_obj = MIME::Lite->new(To=>$recipient, From=>'from@myHost', Subject=>"Web alert web page changed", Type=>'Text', Data=>'For details visit '.$url."\n".$text ); $mail_obj->send; } return 1; }
my $mon = WWW::Monitor->new('MAIL_CALLBACK'=>\¬ify); $mon->watch('http:://www.kahanovitch.com/'); $mon->run;
Description
WWW::Monitor ia a Web monitoring mechanism built to detect and notify changes in web pages. The module is designed to compare existing, online versions of web page and compare it with pre-cached mached version. A web page may uinclude more than one file. A page may include sume frames and visible referenced data, which all together forms a sigle visible page. For now, WWW::Monitor compares only textual information. Images, and non html data are not being compared. Textual informatin is eaxtracled by HTML::FormatText and HTML::TreeBuilder. Text comparation is being done by using Text::Diff module. To store information, WWW::Monitor cache data with "Cache" mechanism. By default, Cache::File is being used but the user may choose to use any Cache object that implements Cache module interface. WWW::Monitor is a subclass of WWW::Mechanize, so any of WWW::Mechanize or its super class can be used.
EXPORT
FUNCTIONS
new ( [ OPTIONS ] )
A constructor. OPTIONS are passed in a hash like fashion, using key and value pairs. Possible options are: URL - A target URL to monitor. CACHE_ROOT - A root directory under which all caching are being managed. Default = <home directory>/.www-monitor CACHE - cache object.The object must have get() and set() methods like Cache interface, as well as set_validity and validity.
watch ( URL(S) )
Add URL to be watched. watch returns a reference to a WWW::Monitor::Task object. for example $obj->watch('http://www.cnn.com' )
notify_callback ( sub )
A code reference to be executed whenever a change is detected (commonly used for sending mail). The following parameters will be passed to the code reference: $url -> a string that holds the url for which a change was detected. $text -> A Message to be sent. $task -> WWW::Monitor::Task object reference. The given code reference should return true for success.
run
Watch all given web page and report a change if detected. If a url is first visited ( i.e. the url is not in the cache db) than the url will be cached and no report will be created.
errors_table
Return a hash reference of errors updated to last execution (i.e. when run method was last executed). The returned keys are the urls where the values are erros description.
errors
return a string that contains all errors. In array context return a list of errors.
notify
(Private Method) Activate notification callback
targets
Return a list of strings out of watched targets.
AUTHOR
Yaron Kahanovitch, <yaron-helpme at kahanovitch.com>
BUGS
Please report any bugs or feature requests to bug-www-monitor at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Monitor. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command. perldoc WWW::Monitor
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2007 Yaron Kahanovitch, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.