Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: check multiple URLS in the same time

by Corion (Pope)
on Aug 23, 2012 at 14:48 UTC ( #989327=note: print w/ replies, xml ) Need Help??

in reply to check multiple URLS in the same time

Here is an example using AnyEvent:

#!/usr/bin/perl use strict; use AnyEvent; use AnyEvent::HTTP; my %urls = ('drudge'=> '', 'rush' =>'', 'yahoo' => '', 'cds' => '',); my $done = AnyEvent->condvar; my @requests; my $count; for my $myURL (sort(values(%urls))){ $done->begin(); $count++; print "Count is $count\n"; push @requests, http_get $myURL => sub { print "Retrieved '$myURL' $_[1]->{Status}\n"; # $_[0] is data # $_[1] is headers $done->end; }; } print "Waiting on requests\n"; $done->recv;

Comment on Re: check multiple URLS in the same time
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989327]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2016-02-14 21:17 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (471 votes), past polls