[109308] in Cypherpunks

home help back first fref pref prev next nref lref last post

POST from perl (Was: teach me how to hack)

daemon@ATHENA.MIT.EDU (Ian Goldberg)
Wed Mar 17 20:18:42 1999

To: cypherpunks@cyberpass.net
From: iang@cs.berkeley.edu (Ian Goldberg)
Date: 18 Mar 1999 00:46:10 GMT
Reply-To: iang@cs.berkeley.edu (Ian Goldberg)

In article <19990315180636.GGDG11681@alaptop.hotwired.com>,
Declan McCullagh  <declan@well.com> wrote:
>Here's an actual serious question:
>
>Using perl, how can I fill out a form on a web site and download the
>resulting page? I certainly know how to download a web page, but there's no
>obvious way to fill out forms.

## The libwww-perl (LWP) package lets you do WWW stuff easily in perl
use LWP;

## Create a UserAgent
$ua = new LWP::UserAgent;

## Create the request; $url is the URL to post to
$request = new HTTP::Request('POST', $url);

## Add headers this way
$request->header(Pragma => 'no-cache');

## Set the POST content this way; change the content to fit your needs
$request->content("passwd=${passwd}&frames=no&disk=${disk}&curmbox=ACTIVE&login=${login}&js=no");

## Use the UserAgent to submit the request and get the response
$response = $ua->request($request);

## Get the body of the response
$body = $response->content;

   - Ian


home help back first fref pref prev next nref lref last post