Skip to content

Instantly share code, notes, and snippets.

@kyuu1999
Created November 2, 2015 02:46
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 kyuu1999/aaa682c8ffc808dd214b to your computer and use it in GitHub Desktop.
Save kyuu1999/aaa682c8ffc808dd214b to your computer and use it in GitHub Desktop.
プルメリアをめっちゃ走らせる
use strict;
use warnings;
use feature qw/say/;
use HTTP::Request::Common;
use LWP::UserAgent;
use Time::HiRes;
use JSON;
my $ua = LWP::UserAgent->new;
$ua->timeout(30);
$ua->env_proxy;
my $tree = new HTML::TreeBuilder::XPath;
my $response = $ua->request( GET 'http://promo.ghm.cave.co.jp/gomafes4' );
if ( $response->is_success ) {
$tree->parse( $response->decoded_content );
my $key = $tree->findnodes('//p[@id="key"]/span')->pop->as_trimmed_text;
while(1){
my $result = $ua->request(
POST 'http://promo.ghm.cave.co.jp/gomafes4/count',
[
key => $key,
count => 50,
],
Accept => 'application/json, text/javascript, */*; q=0.01',
);
my $data;
eval{
$data = decode_json($result->content);
};
$key = $data->{key};
say $data->{count};
Time::HiRes::sleep(0.2);
}
}
else {
die $response->status_line;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment