在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
把post数据写进一个匿名数组里就行 1 #!/usr/bin/env perl -w 2 use strict; 3 use LWP::UserAgent; 4 5 my $ua = LWP::UserAgent->new(); 6 my $rp = $ua->post('http://www.baidu.com', ['username' => 'admin','passwd' => 'password']) 7 print $rp->content(); 或 1 use LWP::UserAgent; 2 my $ua = LWP::UserAgent->new(); 3 4 my $rep = $ua->post('http://localhost/1.php', {cmd => 'whoami'}); 5 #my $rep = $ua->post('http://localhost/1.php', ['cmd' => 'whoami']); 6 print $rep->content; 或 1 use LWP::UserAgent; 2 my $ua = LWP::UserAgent->new(); 3 my $req = HTTP::Request->new(POST => 'http://localhost/1.php'); 4 $req->content('cmd=whoami'); 5 $req->content_type('application/x-www-form-urlencoded'); 6 my $rp = $ua->request($req); 7 print $rp->content;
如果用最后一个方法, 记得要带有content_type头才行
|
请发表评论