in reply to Re: How to get a local form to be 'clicked'?
in thread How to get a local form to be 'clicked'?

Of course I tried $stmt=get("http:...?field1=val1&filed2=val2");
But this is detected as a not correct request and answered
with a "failed-Login" html-page by the server, even in a browser:
within the form method has to be set: method="post"

I just have to load the local form into UserAgent and perfom an request(form->click),
but HOW (?) can I load that damn local html-form-file?
Isn't that just a simple thing?

I tried:
$req = HTTP::Request->new(GET => 'file:/home/../myForm.html'); $res = $ua->request($req);

But $req contains: GET 'file:/home/../myForm.html'
and then this crashes: $ua->request($req)
Carl

Replies are listed 'Best First'.
Re: Re: Re: How to get a local form to be 'clicked'?
by Joost (Canon) on Jun 06, 2002 at 08:40 UTC
    First of all, you can aslo make custom POST requests with LWP::UserAgent by using the $ua->post() call, which will also take parameters as arguments. - I would probably go for that option.

    Second, them HTML::Form documentation is not very clear on exactly what should be passed to HTML::Form->parse(), but a little browsing in the source gives me this working code:

    open HTML,"<./index.html" or die $!; my @forms = HTML::Form->parse(*HTML,'http://localhost/'); close HTML;
    Where the first argument to parse() is the typeglob that contains the filehandle of the HTML file, and the second argument is the base url, which is needed to resolve relative urls in the form.

    Hope this helps :-)

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
Re: Re: Re: How to get a local form to be 'clicked'?
by Anonymous Monk on Jun 06, 2002 at 08:43 UTC
    Got it, thank you for your support. This works:
    $res=$ua->request(POST 'http://..asp',[field1=>'val1',field2=>'val2]);

    carl