Perl script / Curl

I need a Perl script or curl command that searches google.com for a given string...been thru all kinds of documentation on curl and coming up with nothing...can anyone help?
ifeatuAsked:
Who is Participating?
 
Adam314Commented:
You can get the results from google using a URL like so:
    http://www.google.com/#q=string
replace "string" with whatever you want to search.

You can use WWW::Mechanize to get the page...
use WWW::Mechanize;
 
my $mech = WWW::Mechanize->new();
$mech->get('http://www.google.com/#q=string');

Open in new window

0
 
TintinCommented:
When you say you want to search google.com for a given string, do you mean you want to perform a Google search or search for a string on the google page?
0
 
ifeatuAuthor Commented:
yes.  I want to run a google search and show only the top 5 results.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
ifeatuAuthor Commented:
Thanks...worthy of the title Genius!
0
 
ifeatuAuthor Commented:
Hey...I tried using that Perl Module I tried using the get and the 'put' feature, but for some reason I cannot procure the output...here is my code using the 'put' command...the output is absolutely nothing.
use WWW::Mechanize;
 
my $mech = WWW::Mechanize->new();
$mech->put('http://www.google.com/#q=string', 'test' => $tempfile );
print $tempfile;

Open in new window

0
 
Adam314Commented:
Did you get it figured out?  If $tempfile is the name of a file, you can not upload it like that.
0
 
ifeatuAuthor Commented:
No i didn't :-( Still need help I'm a n00b.
0
 
Adam314Commented:
What are you trying to do?  To get the contents from the google page, you can use:
use WWW::Mechanize;
 
my $mech = WWW::Mechanize->new();
$mech->get('http://www.google.com/#q=string');
print $mech->content;

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.