zoukankan      html  css  js  c++  java
  • perl-http

    use LWP::UserAgent;;  
    use HTTP::Request;  
    use HTTP::Response;  
    use HTTP::Request::Common;  
      
    $agent=new LWP::UserAgent;  
    $request=POST('http://localhost:8080/wm/ab',[name=>'zhangsan']);  
    $request->header('User-Agent'=>'Mozilla/5.0 (Windows NT 5.1; rv:10.0.1) Gecko/20100101 Firefox/10.0.1');  
    $request->header('Accept-Encoding'=>'gzip, deflate');  
      
    $response=$agent->request($request);  
    print $response->status_line,"
    ";  
    print $response->content;

    post 传送文件

    use LWP
    require HTTP::Headers;
    $agent = LWP::UserAgent->new;
    
    $response = $agent->post("http://localhost:8080/springtest/fileupload",'Content_Type' => 'multipart/form-data; boundary=----------------------', Content => [
    "user_id"=>"05C30167EA3B4F76AE0D8A4ADB984679",
    'pic' => ["dir"]
    #]);
    print $response->content, "
    ";

    post

    use LWP
    require HTTP::Headers;
    $agent = LWP::UserAgent->new;
    $response = $agent->post("http://localhost:8080/service/store/storeSend", [ "user_id" => "05C30167EA3B4F76AE0D8A4ADB984679" , "bno" => "bnotest001"]);

    get

    #! /usr/bin/perl
    use LWP;
    
    $agent = LWP::UserAgent->new;
    $response = $agent->get("http://istg.xxxx.com/service/store/storeorder/sendandreceive?userid=23812164&deliveryids=&cmd_type=0");
    
    print $response->content, "
    ";

    get add cookie

    #! /usr/bin/perl
    use LWP;
    use HTTP::Cookies;
    
    $agent = LWP::UserAgent->new;
    
    my $cookies = HTTP::Cookies->new();
    $cookies->set_cookie(0,'JSESSIONID', 'A9D5B373B86ACDB04914DEC83E3DA40E','/','store.sf-express.com',80,0,0,86400,0);
    $agent->cookie_jar($cookies);
    $agent->cookie_jar({ 'STORE'=>'STORE_POOL_CNSZ01_49_130_8080', 'JSESSIONID'=> '84BCF81B536D5CB13AFA48E31ACAA6B6' });
    $response = $agent->get("http://store.sf-xxxxx.com/html/admin/user_list.html");
    
    print $response->content, "
    ";

    get add header

    #! /usr/bin/perl
    use LWP;
    use HTTP::Cookies;
    
    $agent = LWP::UserAgent->new;
    
    my @netscape_like_headers = (
    'User-Agent' => 'Mozilla/4.76 [en] (Win98; U)',
    'Accept-Language' => 'en-US',
    'Accept-Charset' => 'iso-8859-1,*,utf-8',
    'Accept-Encoding' => 'gzip',
    'Accept' =>
    "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*",);
    $response = $agent->get("http://store.xxxxxx.com/servlet/storeAction?actionType=list",@netscape_like_headers);
    
    print $response->content, "
    ";

    post add header

    use LWP::UserAgent;;  
    use HTTP::Request;  
    use HTTP::Response;  
    use HTTP::Request::Common;  
      
    $agent=new LWP::UserAgent;  
    $request=POST('http://localhost:8080/wm/ab',[name=>'zhangsan']);  
    $request->header('User-Agent'=>'Mozilla/5.0 (Windows NT 5.1; rv:10.0.1) Gecko/20100101 Firefox/10.0.1');  
    $request->header('Accept-Encoding'=>'gzip, deflate');  
      
    $response=$agent->request($request);  
    print $response->status_line,"
    ";  
    print $response->content;  
  • 相关阅读:
    ORACLE触发器具体解释
    WebStorm 7.0 注冊码
    ZOJ 3794 Greedy Driver spfa
    Linux下的经常使用性能查询命令top、vmstat、gprof、pidstat之对照
    免费的天气预报API--谷歌,雅虎,中央气象台
    div:给div加滚动栏 div的滚动栏设置
    走进小作坊(十一)----移动web实现指南
    执行游戏时出现0xc000007b错误的解决方法
    中国大推力矢量发动机WS15 跨入 世界先进水平!
    tomcatserver乱码问题,tomcat与数据库之间的编码统一转换
  • 原文地址:https://www.cnblogs.com/zengyou/p/3192917.html
Copyright © 2011-2022 走看看