Solved

Perl script / Curl

Posted on 2009-05-12
8
642 Views
Last Modified: 2013-12-16
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
Comment
Question by:ifeatu
  • 4
  • 3
8 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 24370762
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
 

Author Comment

by:ifeatu
ID: 24370847
yes.  I want to run a google search and show only the top 5 results.
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 250 total points
ID: 24371497
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
 

Author Closing Comment

by:ifeatu
ID: 31580807
Thanks...worthy of the title Genius!
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:ifeatu
ID: 24380703
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
 
LVL 39

Expert Comment

by:Adam314
ID: 24398481
Did you get it figured out?  If $tempfile is the name of a file, you can not upload it like that.
0
 

Author Comment

by:ifeatu
ID: 24414714
No i didn't :-( Still need help I'm a n00b.
0
 
LVL 39

Expert Comment

by:Adam314
ID: 24423135
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now