Hi
I tried to use LWP to retrieve information from mapquest.com Basically I want to input street addresses, and scrap distance from the page. The problem is that the information I want to scrap from the web page is dynamic (embedded in JavaScript), so I can't process them using regular expression (although the source codes are viewable via my web browser, but can't process them). Below is my code (doesn't work), and basically I want to extract distance from the web page. Any suggestion on how to fix the code? Thanks...
#!/usr/bin/perl
use strict;
use URI;
use LWP::UserAgent;
use LWP::Simple;
my $url = URI->new("$url->query_form(
"1c"=>"Palo Alto",
"1s"=>"CA",
"1a"=>"1322 Harker Ave",
"1z"=>"94301",
"2c"=>"Palo Alto",
"2s"=>"CA",
"2a"=>"3543 Louis Rd",
"2z"=>"94303");
#print $url;
my $resp=LWP::UserAgent->new->get($url);
#my $resp = get($url);
print $resp->content;
if ($resp=~m/dirDistanceSummary/) {print "$1 \n";}
else {print "No Match!\n"};
I tried to use LWP to retrieve information from mapquest.com Basically I want to input street addresses, and scrap distance from the page. The problem is that the information I want to scrap from the web page is dynamic (embedded in JavaScript), so I can't process them using regular expression (although the source codes are viewable via my web browser, but can't process them). Below is my code (doesn't work), and basically I want to extract distance from the web page. Any suggestion on how to fix the code? Thanks...
#!/usr/bin/perl
use strict;
use URI;
use LWP::UserAgent;
use LWP::Simple;
my $url = URI->new("$url->query_form(
"1c"=>"Palo Alto",
"1s"=>"CA",
"1a"=>"1322 Harker Ave",
"1z"=>"94301",
"2c"=>"Palo Alto",
"2s"=>"CA",
"2a"=>"3543 Louis Rd",
"2z"=>"94303");
#print $url;
my $resp=LWP::UserAgent->new->get($url);
#my $resp = get($url);
print $resp->content;
if ($resp=~m/dirDistanceSummary/) {print "$1 \n";}
else {print "No Match!\n"};