トラックワードのマイページから、検索キーワードの一覧を抽出するための Per lスクリプト。
#!/usr/bin/perl
use strict;
use WWW::Mechanize;
# Setup your trackword account
use constant LOGIN_USERNAME => 'username';
use constant LOGIN_PASSWORD => 'password';
use constant LOGINDEX_URL => 'http://my.trackword.net/userlogindex.phtml';
# Initialize Mechanize object
my $mech = WWW::Mechanize->new
or die 'Failed to initialize <WWW::Mechanize>';
$mech->timeout (30);
# Retrieving user login page
my $res = $mech->get (LOGINDEX_URL);
$res->is_success
or die 'Failed to retrieve the login page';
sleep 1;# thoughtfulness for server
# Login process
$mech->form_number (1)
or die 'Login form is not found';
$mech->set_fields (login => LOGIN_USERNAME, passwd => LOGIN_PASSWORD);
$res = $mech->submit;
$res->is_success
or die 'Failed to submit the form';
sleep 1;# thoughtfulness for server
# Retrieving the trackwords
my $content = $res->content;
while ($content =~ s!<tr>s+<th width="15%" rowspan="d+">s+<b>(S+)s*</b><br>!!s) {
print $1, "
";
}