目的:取得 Skype 可用餘額
Goal: get skype credit balance by perl script
Perl Script:
use LWP::Simple;
use HTML::Parse;
use WWW::Mechanize;
use HTTP::Cookies;
use LWP::Debug qw(+);
$account1 = "Your_Skype_account";
$passwd1 = "Your_Skype_password";
$credit1 = get_credit($account1, $passwd1);
print "$credit1\n";
sub get_credit {
my $url = "https://login.skype.com/intl/zh-Hant/account/login-form";
my $username = $_[0];
my $password = $_[1];
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_id('loginForm');
$mech->field(username => $username);
$mech->field(password => $password);
$mech->click();
my $output_page = $mech->content();
$page_text = parse_html($output_page)->format;
@tmp = split(/NT\$/, $page_text);
@tmp2 = split(/\s+/, $tmp[1]);
$credit_balance = @tmp2[1];
return $credit_balance;
}
原本參考的網頁說 use LWP::Debug qw(+); 可以看到 debug message,但是我加上這一行沒反應。
沒有留言:
張貼留言