------------------------------------------------
On Fri, 15 Aug 2003 22:29:46 +0530, Sukrit K Mehra <[EMAIL PROTECTED]> wrote:

> Hi listers,
> 
> This is the code of the form. From the website www.m-w.com; for which I
> am trying to make a client.
> 
> <form name="dict" method="post" action="/cgi-bin/dictionary">
>   <td valign="middle" width="223" align="center">
>   <input type="hidden" name="book" value="Dictionary">
>   <font color="#ffffff" size="2" face="Arial,
> Helvetica"><strong>Merriam-Webster Dictionary</strong></font>
> 
>   </td><td valign="middle" width="130">
>   <input name="va" size="15">
>   <script language=Javascript>document.dict.va.focus();</script>
>   </td><td valign="middle" width="100">
>   <input type="submit" value="Look it up">
>   </td>
>   </form>
> 
> This is my code. Unfortunately I haven't been able to figure out the
> exact request parameters.
> 
>   my $url = 'http://www.m-w.com';
>   my $ua = LWP::UserAgent->new();
>   $ua->agent("My Browser 0.1");
>   my $request = HTTP::Request->new(GET => $url);
>   $request->content_type('application/x-form-urlencoded');
> #Here is where I need help!
>   $request->content('name=hdwd value=hello');
>   my $response = $ua->request($request);
>   print $response->content;
> 

I assume you don't want to use:

http://search.cpan.org/author/NEILB/Net-Dict-2.07/lib/Net/Dict.pod

In any case... the URL you will need in the above will need to be that of the form, 
not the homepage.

$url = 'http://www.m-w.com/cgi-bin/dictionary';

And your content will need to be the key/value pairs from the input fields of the form 
which you posted, they are the following:

book=Dictionary
va=$your_word

So you end up with the following, which is NOT tested:

# Create a request
my $req = HTTP::Request->new(POST => 'http://www.m-w.com/cgi-bin/dictionary');
$req->content_type('application/x-www-form-urlencoded');
$req->content('book=dictionary&va=test+word');

# Pass request to the user agent and get a response back
my $res = $ua->request($req);

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to