Created
July 12, 2012 16:03
-
-
Save ceekz/3099041 to your computer and use it in GitHub Desktop.
An IP address is used at random.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# サーバに割り当てた任意の 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