[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Accessing html forms...



On Wed, 3 Jun 1998, Chris wrote:

> Sorry, I think we've got confussed.  I know perl very well, and as
> Ralph said it has proved invaluable.  However, what I want to do is
> ~send~ something to a html server via a POST operation.

what you want is LWP (the libwww-perl package).

I have used this to do both GET and POST requests from within a perl
script (e.g. i wrote a q&d hack to send the Subject: line of an email
message sent to a certain address via a free WWW to SMS service).

According to the manpage, LWP is capable of GET, PUT, POST, and HEAD
methods.  it can be used for many things, but it is ideal for writing perl
web-bots. 

here's an example from 'man LWP'.  

       An Example

       This example shows how the user agent, a request and a
       response are represented in actual perl code:

         # Create a user agent object
         use LWP::UserAgent;
         $ua = new LWP::UserAgent;
         $ua->agent("AgentName/0.1 " . $ua->agent);

         # Create a request
         my $req = new HTTP::Request POST => 'http://www.perl.com/cgi-bin/BugGlimpse';
         $req->content_type('application/x-www-form-urlencoded');
         $req->content('match=www&errors=0');

         # 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 "Bad luck this time\n";
         }

       The $ua is created once when the application starts up.
       New request objects are normally created for each request
       sent.



BTW, there are several man pages for LWP.  Read/print them all :-)

craig

--
craig sanders


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: