用IO::Socket实现POST的代码

此博客展示了一段Perl代码,利用IO::Socket模块创建套接字,向指定主机和端口发起HTTP POST请求。代码中设置了请求头和请求体等信息,最后打印出响应内容,涉及socket、IO等信息技术相关内容。
#!/usr/bin/perl     
#####################################
# jondy
# QQ:222411
# http://blog.youkuaiyun.com/jondynet
#####################################

use strict;
use warnings;
use IO::Socket;

my $host = "221.208.250.138";
my $port = "80";
my $sock = IO::Socket::INET->new("$host:$port") 
|| die "Socket() error, Reason : $! /n";

print $sock "POST /secu/fch_hljcontentauthact.jsp?isADSL=0
&qs=cmV0dXJsPWh0dHA6Ly8yMjEuMjA4LjI1MC4xMzgvZm
NoX2xvZ2luL2xvZ2luLmpzcCZpY3BpZD0xMDAxJmZvcmNl
bG9naW49MCZpc3BpZD0xMDAwMSZjaGFsbGVuZ2U9MTEzND
c5MTg5NDc3MSZ0aW1ld2luZG93PTEyMzQ1Ng== HTTP/1.1/r/n";
print $sock "Accept: image/gif, image/x-xbitmap, image/jpe
g, image/pjpeg, application/x-shockwave-flash, */*/r/n";
print $sock "Accept-Language: zh-cn/r/n";
print $sock "Content-Type: application/x-www-form-urlencoded/r/n";
print $sock "Accept-Encoding: gzip, deflate/r/n";
print $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.2; .NET CLR 1.1.4322)/r/n";
print $sock "Host: $host/r/n";
print $sock "Content-Length: 105/r/n";
print $sock "Connection: Keep-Alive/r/n";
print $sock "Cache-Control: no-cache/r/n";
print $sock "/r/n";
print $sock "stopformer=false&clientusername=&showordernot
ice=1&localIP=&usernameinput=username&password
input=123456/r/n";
print $sock "/r/n";
print <$sock>;
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值