On Friday 10 December 2004 22:24, [EMAIL PROTECTED] wrote:
> Hi guys,

Hi Diogo,

>
> As you know, iŽm having some problems to make this thing work. I have to
> write a script that automatically sends a code and get the some
> information according to that code. I mean, this script has to
> automatically fill in a formfield and get the result. 

Could you describe in more detail what exactly you're trying to do?
If I type the first URL you posted into my browser, I get a page with three 
pairs on input fields and submit buttons - which one do you want to fill out, 
and what should happen after you pressed the submit button?

> But I just canŽt get it done. 

Why? What exactly is the problem? Do you get an error message? Do you have a 
specific question?

> If youŽre really really in the mood for helping me, IŽm posting 
> down here the source code of the page of the form that the script must
> fill in and get the result. The url is:
> http://www.tj.go.gov.br/online/Inicial/Processos/ConsultaProc_1Grau_Capital
>.dml And here is the URL for the page that returns the result:
> http://www.tj.go.gov.br/online/Capital/Processos_SPG/Resp_Processo1.dml
> After this source code, youŽll see the code of my script, please, help me!

[.. snipped approximately 3 GB of HTML source code ;-) ..]
>
>
> PERL Script
> #!/usr/bin/perl

Just a small hint: Always put the following lines at the beginning of a 
script:

use strict;
use warnings;

You've got to get used to it - e.g. you've got to declare all your variables 
before using them, like:
  my $ua = LWP::UserAgent->new();
instead of 
  $ua = ...
But in the long run, it will help you avoid making error)

>   use LWP::UserAgent;
>   $ua = LWP::UserAgent->new;
>   $ua->agent("MyApp/0.1 ");
>   $ua->cookie_jar({});
>
> my $req = HTTP::Request->new(POST =>
> 'http://www.tj.go.gov.br/online/Capital/Processos_SPG/Resp_Processo1.dml');

Judging by the HTML code you posted, you probably do not want to submit a POST 
request, but a GET request instead. The relevant part of the HTML code is:

<form METHOD="GET" ACTION="../../Capital/Processos_SPG/Resp_Processo1.dml" 
NAME="form1" ONSUBMIT="return valida(document.form1.numrproc.value);">

Note the METHOD="GET" part - this specifies that this form initiates a GET 
request when you press the submit button.I don't know off the top of my head 
how to send a GET request using LWP::UserAgent - the short version might be 
something like this (not tested, take a look at the module documentation for 
the correct syntax):

my $ua = new LWP::UserAgent();
my $url_to_send = 
'http://the_server.com/full/address/to/document?parameter=value';
my $response = $ua -> get($url);
print "response : $response\n";

> #my $req = HTTP::Request->new(POST =>
> 'http://www.tj.go.gov.br/online/Inicial/Processos/ConsultaProc_1Grau_Capita
>l.dml'); $req->content_type('application/x-www-form-urlencoded');
> $req->content('numrproc=009600352534');
> #&mode=dist');
>
>   my $res = $ua->request($req);
>
>   if ($res->is_success) {
>       print $res->content;
>   }
>   else {
>       print $res->status_line, "\n";
>   }

Hope this helps - if you run into problems with this, write to the list what 
you tried and what you got in result. I'm sure somebody can help you.

Philipp

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to