Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 664
  • Last Modified:

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?
0
ifeatu
Asked:
ifeatu
  • 4
  • 3
1 Solution
 
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
 
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now