Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
use utf8;
use strict;
use warnings;
use WWW::Mechanize;
use Encode;
use Config::Pit;
use HTML::TreeBuilder::XPath;
my $config = pit_get("", require => {
"username" => "your username on example",
"password" => "your password on example"
my $mech = WWW::Mechanize->new;
$mech->agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1");
form_name => 'auLogin',
fields => {
UserID => $config->{username},
Password => $config->{password},
$mech->submit_form( form_name => 'recentcharge');
$mech->submit_form( form_name => 'formIsPacketSu');
my $html = decode('Shift_JIS', $mech->res->content);
my ($details) = ($html =~ m{<h4>日毎の内訳</h4>([\s\S]+?)</table>});
my $matched = [ $details =~ m{\((\d\d\d\d)/(\d\d)/(\d\d)\)[\s\S]*?([\d,]+)\s*パケット}g ];
while (my ($year, $month, $day, $packets) = splice @$matched, 0, 4) {
$packets =~ s{,}{}g;
use Data::Dumper;
warn Dumper +{
year => $year,
month => $month,
day => $day,
packets => $packets,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.