Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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 romping around the Monastery: (7)
As of 2015-11-30 23:16 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (788 votes), past polls