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?

Improve company productivity with a Business Account.Sign Up

x
 
Adam314Connect With a Mentor Commented:
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
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

 
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.