• perl发送post数据


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

  • 相关阅读:
    WHENEVER SQLERROR EXIT AND DDL
    WHENEVER SQLERROR EXIT AND DML
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
  • 原文地址:https://www.cnblogs.com/perl6/p/6447365.html
Copyright © 2020-2023  润新知