got_quail has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I'm new to Perl (and perlmonks), so hopefully this isn't embarassing:
I'm looking for a way to pop up the resulting webpage of a search I have defined in my script.
I'm using LWP to input my search parameters and execute the search too, but what I get back is the HTML code corresponding to the result page. I want to actually launch that page from the search engine server to retain the formatting and everything. Basically I want to request the page and give it my input parameters at the same time.
Also, for some search engines I've tried I'm getting null results for valid search parameters, so I'm wondering if it's even possible to use LWP requests for the site I have in mind, but I guess that is a whole other question.
The following is the example I'm following, from CPAN:
use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); # Create a request my $req = HTTP::Request->new(POST => 'http://search.cpan.org/search' +); $req->content_type('application/x-www-form-urlencoded'); $req->content('query=libwww-perl&mode=dist'); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Automated Browsing
by dasgar (Priest) on Jan 28, 2011 at 03:09 UTC | |
|
Re: Automated Browsing
by Marshall (Canon) on Jan 28, 2011 at 04:51 UTC | |
|
Re: Automated Browsing
by zentara (Cardinal) on Jan 28, 2011 at 12:00 UTC | |
|
Re: Automated Browsing
by got_quail (Initiate) on Jan 28, 2011 at 21:10 UTC |