Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

www::mechanize google search

by gauravtechie (Initiate)
on Nov 23, 2007 at 21:26 UTC ( [id://652667]=perlquestion: print w/replies, xml ) Need Help??

gauravtechie has asked for the wisdom of the Perl Monks concerning the following question:

Hi ! I am new to perl and perlmonk , i tried www::mechanize module for making a maps google site crawler The code is
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $queryString1 = 'restaurant'; my $queryString2 = 'New Delhi'; my $url = 'http://www.maps.google.com/maps?f=l&hl=en&geocode=&time=&da +te=&ttype=&view=text'; my $mechObject = WWW::Mechanize->new( autocheck => 1 ); $mechObject -> get($url); $mechObject->form_number(1); $mechObject->field("q", $queryString1); $mechObject->field("near", $queryString2); $mechObject->click("btnG"); print $mechObject -> content
But the script terminate with No such field 'near' at /usr/local/share/perl/5.8.8/WWW/Mechanize.pm line 1227 But i can see near tag in url ?

Replies are listed 'Best First'.
Re: www::mechanize google search
by erroneousBollock (Curate) on Nov 24, 2007 at 03:37 UTC
    Like most other Google services, I'm pretty sure they don't give you permission to scrape info from their HTML pages. Here are the terms of use.

    Google provides a Google Maps "mashup" (Javascript) API which is quite easy to integrate with. You'll need to sign up for a (free) license key.

    The easiest way I can think to integrate the Maps API with perl is to run it in a locally served (say with HTTP::Daemon) web-page via Mozilla::Mechanize. You can then add AJAX (XMLHttpRequest) calls to your page to pass info back to your perl code.

    -David

Re: www::mechanize google search
by pc88mxer (Vicar) on Nov 23, 2007 at 22:28 UTC
    I think you need to switch to form #2. There are three forms on that page, and the "near" input field is located in the second one (id="l_form")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://652667]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found