Forum Moderators: coopster & phranque

Message Too Old, No Replies

Automatically fill in a web-form field

         

diogonunes

9:22 pm on Dec 3, 2004 (gmt 0)

10+ Year Member



Hi guys,

I need your help. I wanna make a script that automatically consults some information using a code.
It´s like this. I use a website to get some information using a code. There´s a form, I fill-in a form-field and submit, then I get the result. I want to make a script that reads all the codes from a file, sends each code to that website, and get the result about that code.
So, i beleive I need a 'put' method. And how do I do so?
help me!

Diogo Nunes de Oliveira

DrDoc

11:19 pm on Dec 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you looked into cURL or LWP? Both are very easy to use for what you want to do.

diogonunes

10:31 pm on Dec 10, 2004 (gmt 0)

10+ Year Member



Actually I tried LWP::UserAgent, but I can´t get it done. I used this module and tested it searching for a module at search.cpan.org/search. It works fine, but when I try to use it in the website that I need, it doesn´t work. If you wanna help me out guys, I´m posting here the URL used to type the code (which is used to make the search), the URL that returns the result and my script.
Thanks!
URL/Form:
[example.br...]

URL/Result:
[example.br...]

My script:
#!/usr/bin/perl
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
$ua->cookie_jar({});

my $req = HTTP::Request->new(POST => 'http://www.example.br/online/Capital/Processos_SPG/Resp_Processo1.dml');
#my $req = HTTP::Request->new(POST => 'http://www.example.br/online/Inicial/Processos/ConsultaProc_1Grau_Capital.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";

[edited by: jatar_k at 6:05 pm (utc) on Dec. 11, 2004]
[edit reason] generalized urls [/edit]