Skip to content

Instantly share code, notes, and snippets.

@clairvy
Forked from typester/outputz-growl.pl
Created October 16, 2009 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clairvy/211498 to your computer and use it in GitHub Desktop.
Save clairvy/211498 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# -*- coding: utf-8-unix; -*-
use strict;
use warnings;
use Config::Pit;
use Net::Growl;
use WWW::Mechanize;
my $conf = pit_get('outputz.com', require => { key => 'your outputz secret key' });
my $mech = WWW::Mechanize->new( stack_depth => 1 );
$mech->get('http://outputz.com/daily');
$mech->follow_link(url_regex => qr/config/);
$mech->submit_form(
fields => {
magic_word => $conf->{key},
},
);
unless ($mech->content =~ /$conf->{key}/) {
die 'login failed';
}
$mech->get('http://outputz.com/daily');
my ($rank, $info) = $mech->content =~ m!<p class="ranking">(\d+)(?:<span class="ranking_info">(.*?)</span>)?</p>!;
die 'html parse failes' unless $rank;
$info = '' unless (defined($info));
my $gconf = pit_get('growl', require => { password => 'your growl network password' });
register(
host => '127.0.0.1',
application => 'outputz notifier',
password => $gconf->{password},
);
notify(
application => 'outputz notifier',
title => 'this hour outputz rank',
description => $rank . $info,
password => $gconf->{password},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment