in reply to Re^2: regexp solutions
in thread regexp solutions
Sure, it should be as simple as putting it all in a loop. Just put your urls into single quoted strings, and separate with a comma, as shown below.
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common qw(GET); use HTML::TokeParser::Simple; my $ua = LWP::UserAgent->new; # Define user agent type $ua->agent('MyApp/0.1 '); my @requests = ( 'http://finance.yahoo.com/actives?e=us', 'http://finance.yahoo.com/actives?e=o AMEX', 'http://finance.yahoo.com/actives?e=aq', 'http://finance.yahoo.com/actives?e=nq', ); # loop thru them foreach my $requested ( @requests ) { print "STARTING $requested ###########################\n\n\n\n\n"; # Request object my $req = GET $requested; # Make the request my $res = $ua->request($req); my $con = $res->content; #print "$con\n"; my $p = HTML::TokeParser::Simple->new( \$con ); while ( my $token = $p->get_token ) { # This prints all text in an HTML doc (i.e., it strips the HTML) next unless $token->is_text; print $token->as_is, "\n"; } print "ENDING $requested ###########################\n\n\n\n\n\n"; } # end of loop exit 0;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: regexp solutions
by programmer.perl (Beadle) on Jul 05, 2012 at 07:27 UTC | |
Re^4: regexp solutions
by programmer.perl (Beadle) on Jul 05, 2012 at 16:59 UTC | |
by zentara (Cardinal) on Jul 05, 2012 at 17:19 UTC |