The following shell one-liner does the job, but slowly:
wget -qO - https://username:password@mail.google.com/mail/feed/atom --no-check-certificate \
| egrep '[0-9]+ ' \
| sed -e 's/[^0-9]//g'
Here's a simple perl script that is about twice as fast:
#!/usr/bin/perl
use strict;
use warnings;
use XML::Atom::Client;
my $api = XML::Atom::Client->new;
$api->username('username');
$api->password('password');
my $feed = $api->getFeed('https://mail.google.com/mail/feed/atom')
or die ("Error: ", $api->errstr, "\n");
print(scalar($feed->entries)||0, "\n");
On ArchLinux this required the following packages:
perl-xml-atom, perl-libwww, perl-digest-sha1, perl-datetime, perl-crypt-ssleay
.
No comments:
Post a Comment