DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Perl - Send Form POST

12.18.2006
| 22029 views |
  • submit to reddit
        // Manda le informazioni per il login ad un determinato sito

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

my $user = "user";
my $pass = "pass";

my $browser = LWP::UserAgent->new();

my $responde = HTTP::Request->new(POST => "http://www.sito.com/index.php");
$responde->content_type("application/x-www-form-urlencoded");
$responde->content("user=" . $user . "&pass=" . $pass);

$browser->request($responde)->as_string
    

Comments

Snippets Manager replied on Wed, 2008/07/30 - 4:40pm

all form fields' names and values should be passed through urlencode()