Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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'=> 'http://www.drudgereport.com', 'rush' =>'http://www.rushlimbaugh.com/home/today.guest.html', 'yahoo' => 'http://www.yahoo.com', 'cds' => 'http://www.cdsllc.com/',); 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2014-08-23 20:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls