
davorg
Thaumaturge
/ Moderator
Jul 4, 2003, 2:57 AM
Post #4 of 6
(428 views)
|
|
Re: [peterhall] Using LWP query
[In reply to]
|
Can't Post
|
|
I'm not sure I really understand what you're asking. What do you mean by "lwp-query". To post an query to a web server you used LWP::UserAgent and HTTP::Request (or, to make live easier, HTTP::Request::Common). There are examples of both of these in lwpcook.
use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = LWP::UserAgent->new; my $req = POST 'http://www.perl.com/cgi-bin/BugGlimpse', [ search => 'www', errors => 0 ]; print $ua->request($req)->as_string; The only variable parts of the request are the URL which passed as the first argument to POST and the set of parameters which are passed in the anonymous array which is the second argument. So basically the steps are: 1/ Create an LWP::UserAgent object. 2/ Create an HTTP::Request object giving both the URL and the parameters. 3/ Use the useragent object to run the request object (using the "request" method. 4/ The returns an HTTP::Response object which tells you what was returned by the server. The example just uses the "as_string" method to display the output. So what part fo you need more help with? -- Dave Cross, Perl Hacker, Trainer and Writer http://www.dave.org.uk/ Get more help at Perl Monks
|