Skip to content

Instantly share code, notes, and snippets.

@alecchen
Created January 12, 2012 17:07
Show Gist options
  • Save alecchen/1601775 to your computer and use it in GitHub Desktop.
Save alecchen/1601775 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use Modern::Perl;
use Smart::Comments;
use WWW::Mechanize;
use Mojo::DOM;
use Readonly;
Readonly my $TOUR_URL => 'http://radiohead.com/tourdates/';
Readonly my $GIG_URL => 'http://radiohead.com/tourdates/25-07-12_taipei';
Readonly my $TOUR_STATUS => 'Wed 25 Nanang Exhibition Hall Taipei Taiwan ON SALE 13 JAN';
Readonly my $GIG_STATUS => 'From 13 Jan at W.A.S.T.E. '
. 'From 15 Jan at G-Music (8pm local time)';
my $mech = WWW::Mechanize->new;
my $dom = Mojo::DOM->new;
while (1) {
$mech->get($TOUR_URL);
$dom->parse($mech->content);
my $tour_status = (grep { /taipei/i }
map { $_->all_text } $dom->find('div[class="date"]')->each)[0];
### [<now>]: $tour_status
last if $tour_status ne $TOUR_STATUS;
$mech->get($GIG_URL);
$dom->parse($mech->content);
my $gig_status = $dom->find('div[class="tickets"]')->first->all_text;
### [<now>]: $gig_status
last if $gig_status ne $GIG_STATUS;
sleep 20;
}
### ON SALE NOW
while (1) { system "say radiohead"; sleep 1 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment