Skip to content

Instantly share code, notes, and snippets.

@aggrolite
Created February 18, 2013 22:53
Show Gist options
  • Save aggrolite/4981508 to your computer and use it in GitHub Desktop.
Save aggrolite/4981508 to your computer and use it in GitHub Desktop.
check for Yosemite hotels
use strict;
use warnings;
use HTML::TreeBuilder::XPath;
use LWP::Simple qw(get);
use Net::SMTP;
use URI;
my $uri = URI->new('https://gc.synxis.com/rez.aspx');
$uri->query_form(
Chain => 398,
start => 'availresults',
wsi => '',
arrive => '6/19/2013',
depart => '6/23/2013',
adult => 2,
child => 0,
Hotel => 400,
rcp => '',
);
while (1) {
my $c = get($uri->as_string);
my $tree = HTML::TreeBuilder::XPath->new_from_content($c);
my $empty = $tree->exists(
'.//div[@class=~/\bAvailResults\b/]
//span[@class=~/\bNoAvailMsg\b/ and .=~/\bThere are no available rooms\b/]'
);
print $empty ? "Found no hotels\n\n" : "Found hotel(s) at " . $uri->as_string . "\n\n";
unless ($empty) {
my $smtp = Net::SMTP->new('smtp.foo.com');
$smtp->mail('[email protected]');
$smtp->to(qw( [email protected] ));
$smtp->data();
$smtp->datasend(sprintf(<<END_MSG, $uri->as_string));
Hello,
I think I might have found an available Housekeeping Camp:
%s
END_MSG
$smtp->dataend();
$smtp->quit();
}
sleep(1200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment