Skip to content

Instantly share code, notes, and snippets.

@ceekz
Created Jul 12, 2012
Embed
What would you like to do?
An IP address is used at random.
# サーバに割り当てた任意の IP アドレスを利用する
# (本コードではランダムに選択)
use LWP::UserAgent (@LWP::Protocol::http::EXTRA_SOCK_OPTS);
# ランダムに IP を選択
{
my @IP = qw(
203.0.113.1
203.0.113.2
203.0.113.3
203.0.113.4
203.0.113.5
);
push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, LocalAddr => $IP[rand(@IP)]);
}
my $ua = LWP::UserAgent->new(agent => 'Bot/0.1', keep_alive => 1);
my $html = $ua->get('http://www.example.com/')->content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment