开发者

Loop in Perl - with LWP::UserAgent

开发者 https://www.devze.com 2023-01-26 08:48 出处:网络
Here the code that has needs to be build in loop - to make USER-Agent to iterate over a bunch of targets.

Here the code that has needs to be build in loop - to make USER-Agent to iterate over a bunch of targets.

 for my $i (1..10000) {
     my $request = HTTP::Request->new(GET =>
sprintf("http://www.example.com,%d", $i));

Is this the correct way to iterate? I love to hear from you ... to get a 开发者_如何学编程starting-point...


Just a suggestion, you may want to use WWW::Mechanize instead, which is a handy sub-class for the LWP::Module. For what you want to do the code could look like this:

foreach my $i (1..1000)
{
   #$mech is a object for WWW::Mechanize
   $mech->get("http://yourtarget.com/whateveryouwant"); 
}

Then you can sort the results e.g. by response code (404 - Not Found, 200 - OK...) by checking $mech->status()

0

精彩评论

暂无评论...
验证码 换一张
取 消