Last active
December 19, 2015 10:19
-
-
Save zatarra/5939714 to your computer and use it in GitHub Desktop.
Simple URL checker. All it does is check a predefined url to see if it has changes over the time. If it did , then it sends you an e-mail. It is useful when your are waiting for something on a website to change!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -W | |
use strict; | |
use warnings; | |
use LWP::Simple; | |
use Digest::MD5 qw(md5 md5_hex md5_base64); | |
use Encode qw(encode_utf8); | |
my $link = [URL TO BE CHECKED]; | |
my $email_from = [FROM EMAIL]; | |
my $email = [TO EMAIL]; | |
my $email_subject = 'Website Changed!'; | |
my $email_body = 'Hello! I just want to let you know that the website ' | |
. $link . ' has just changed!'; | |
my $tmp_file = '/tmp/stored_hash'; | |
my $web_source = get( $link ); | |
my $current_hash = md5_hex(encode_utf8($web_source)); | |
if(-e $tmp_file) | |
{ | |
open FH, "<$tmp_file" or die "could not open: $!\n"; | |
my $mod_hash = <FH>; | |
if( $current_hash ne $mod_hash ) | |
{ | |
open(MAIL, "|/usr/sbin/sendmail -t"); | |
print MAIL "To: $email\n"; | |
print MAIL "From: $email_from\n"; | |
print MAIL "Subject: $email_subject\n\n"; | |
print MAIL "$email_body\n"; | |
close(MAIL); | |
} | |
close FH; | |
} | |
open FH, ">$tmp_file" or die "could not create: $!\n"; | |
print FH $current_hash; | |
close FH; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment