zoukankan      html  css  js  c++  java
  • perl 访问网站一些useragent的设置

    121.40.205.143 - - [22/Jun/2016:12:56:23 +0800] "GET /wechat/account.html HTTP/1.1" 200 3432 "-" "Mozilla/8.0"  --此时地址为haproxy的地址 
    
    
    
    
    120.55.118.6 - - [22/Jun/2016:13:07:26 +0800] "GET /wechat/account.html HTTP/1.1" 200 3432 "-" "Mozilla/8.0"
    
    
    从wx03-120.55.118.6 访问 
    use  LWP::UserAgent;
    
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    #$ua->env_proxy('http','http://$ARGV[0]');
    $ua->agent("Mozilla/8.0");
    
    my $response = $ua->get('https://uatest.xxx.com/wechat/account.html');
    
    
    if ($response->is_success) {
     print $response->decoded_content;  # or whatever
    }
    else {
     die $response->status_line;
    }
    ~                                                                                                                                                                                                                                
    ~ 
    
    此时useragent为Mozilla/8.0
    
    
    
    
    修改脚本:
    
    
    use  LWP::UserAgent;
     
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    #$ua->env_proxy('http','http://$ARGV[0]');
    #$ua->agent("Mozilla/8.0");
    
    my $response = $ua->get('https://uatest.xxx.com/wechat/account.html');
    
    
    if ($response->is_success) {
     print $response->decoded_content;  # or whatever
    }
    else {
     die $response->status_line;
    }
    
    
    
    121.40.205.143 - - [22/Jun/2016:13:08:54 +0800] "GET /wechat/account.html HTTP/1.1" 200 3432 "-" "libwww-perl/6.15"
    
    

  • 相关阅读:
    数据库优化
    Oracle语句集锦
    MVC Razor标签
    转载 操作MyBatis基础
    mysql sqlserver Oracle字符串连接
    Word
    部署IIS错误
    => 朗姆达表达式带入符号
    wcf例子01
    idea通过springboot初始化器新建项目
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350665.html
Copyright © 2011-2022 走看看