CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Simulating a POST action

 



Steerpike
Deleted

Mar 24, 2000, 5:20 PM

Post #1 of 2 (416 views)
Simulating a POST action Can't Post

Hi and many thanks in advance to one and all Smile

What I would like to do is have a program which parses the HTML of a webpage, the webpage being retrieved using LWP::Simple and the get command.

However, if the webpage being retrieved was generated by a CGI script given certain query data, how can I pass data to the script if it requires the POST action to be used? Smile

Obviously for a GET action I would include the data in the URL I requested, eg:

use LWP::Simple;

$HTML=get("http://www.example.com/example.cgi?Name=Dirk");

But how can I run the script using the POST action rather than GET? Smile

Thanks all Smile


japhy
Enthusiast

Mar 24, 2000, 5:38 PM

Post #2 of 2 (416 views)
Re: Simulating a POST action [In reply to] Can't Post

You can't use LWP::Simple for this. You'll need LWP::UserAgent. Example:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use LWP::UserAgent;

$client = new LWP::UserAgent;
$req = new HTTP::Request POST => "http://www.server.com/cgi-bin/prog.cgi", [ name => "jeff", age => 18 ];
$return = $client->request($req);
</pre><HR></BLOCKQUOTE>

Read the lwpcook documentation that comes with the LWP suite of modules.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives