加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl http get和post

发布时间:2020-12-16 00:33:25 所属栏目:大数据 来源:网络整理
导读:? 转载地址: http://mutudumutu.spaces.live.com/blog/cns!495E756F3B5E8D74!135.entry #! /usr/bin/perl -w #www_get.pl #这是学习perl编程的代码 #HTTP协议的GET操作 #author: mutudumutu@hotmail.com #date:2006-03-03 # use strict; use LWP::UserAgent
?

转载地址:http://mutudumutu.spaces.live.com/blog/cns!495E756F3B5E8D74!135.entry

#! /usr/bin/perl -w #www_get.pl #这是学习perl编程的代码 #HTTP协议的GET操作 #author: mutudumutu@hotmail.com #date:2006-03-03 # use strict; use LWP::UserAgent; my $method = shift || 'GET'; my $server_name = shift || 'localhos'; my $port_number = shift || 80; my $page = shift || 'index.html'; my $url = 'http://'. $server_name . ':'. $port_number.'/' . $page; my $request = new HTTP::Request $method => $url; my $useragent = new LWP::UserAgent; my $response = $useragent->request( $request ); print $response->as_string; __END__ ======================================= 下面这个可以提交数据的 #! /usr/bin/perl -w #www_post.pl #这是学习perl编程的代码 #HTTP协议的POST操作 #author: mutudumutu@hotmail.com #date:2006-03-03 # use strict; use LWP::UserAgent; use HTTP::Request::Common; #得到要提交的参数 my $server_name = shift || 'localhost'; my $port_number = shift || '8443'; my $page = shift || 'formtest.do'; my $url = 'https://'. $server_name . ':'. $port_number.'/' . $page; my $useragent = new LWP::UserAgent; my $response = $useragent->request(POST $url,[para1=>'value1',para2=>'value2']); print $response->as_string; __END__ 虽然这两个代码很弱,但是对Http的Get和Post都有了,与Http的交互可以从这两个代码扩展。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读