把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头才行

 

相关文章:

  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2021-07-10
  • 2021-06-04
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案