perl 使用post和get

url 传参格式:

perl get 方式请求:

use Encode;
use Encode::CN;
use JSON; 
use URI::Escape;
use LWP::Simple;
#$host = "http://ip.taobao.com/service/getIpInfo.php?ip=202.101.172.35";
$host = " http://211.149.197.95:8888/sms.aspx?action=send&userid=74&account=xx&password=xx&mobile=18072xx7&content=内容&sendTime=&extno=";
$content = get($host);
print "\$content is $content\n";


通过get方式请求,参数所以用“&”符号来隔开。



perl post 方式请求:

use strict;
use LWP;

my $browser = LWP::UserAgent->new();
my $response= $browser->post("http://211.149.197.95:8888/sms.aspx", [ "action" => "send" , "userid" => "74","account" => "xx","password" => xx,"mobile" =>180xx237,"content" =>"test0612"]); #多加了

一个被发送的数据的数组

print $response->content; # 输出获得的网页内容

你可能感兴趣的:(perl 使用post和get)