Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
プルメリアをめっちゃ走らせる
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
You can’t perform that action at this time.