zoukankan      html  css  js  c++  java
  • perl 通过代理 访问

    获取代理地址:
    49.94.146.182:3128[root@dr-mysql01 test]# cat get.pl 
    use  LWP::UserAgent;
     
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    $ua->env_proxy;
    $ua->agent("Mozilla/8.0");
    
    my $response = $ua->get('http://www.kuaidaili.com/api/getproxy?orderid=963771205365827&num=9999');
    
    
    if ($response->is_success) {
     print $response->decoded_content;  # or whatever
    }
    else {
     die $response->status_line;
    }
    
    
    [root@dr-mysql01 test]# perl get.pl | more
    117.177.243.111:8080
    218.92.227.168:34034
    223.85.83.47:8123
    117.177.243.38:83
    207.5.112.114:8080
    111.12.117.68:8082
    117.177.243.56:86
    117.177.243.39:8081
    204.27.58.202:811
    
    
    代理服务器使用:
    3.代理属性
    $ua->proxy(@schemes, $proxy_url) 
    $ua->proxy($scheme, $proxy_url) 
    如 
     $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
     $ua->proxy('gopher', 'http://proxy.sn.no:8001/');
    指明通过制定的代理服务器,按照指定的协议方法访问。
    
    
    jrhmpt01:/root/test# cat get.pl 
    use  LWP::UserAgent;
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    #$ENV{HTTPS_PROXY} = "http://$ARGV[0]";
    $ua->agent("Mozilla/8.0");
    $ua->proxy('http',"http://$ARGV[0]");
    print $ua->proxy('http',"http://$ARGV[0]")."
    ";
    
    my $response = $ua->get('http://wenjinbao.winfae.com');
    
    
    if ($response->is_success) {
     print $response->decoded_content;  # or whatever
    }
    else {
     die $response->status_line;
     }
    
    
    
    
    
    Jul 24 13:24:49 localhost haproxy[11504]: 218.92.227.165:40427 [24/Jul/2015:13:24:49.633] www~ webserver_8001/webhost02_8001 146/0/1/1/148 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:08 localhost haproxy[11452]: 115.236.160.82:46444 [24/Jul/2015:13:25:08.582] www webserver_8001/webhost01_8001 81/0/1/1/83 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:08 localhost haproxy[11452]: 115.236.160.82:46445 [24/Jul/2015:13:25:08.888] www webserver_8001/webhost02_8001 75/0/1/1/77 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:09 localhost haproxy[11452]: 115.236.160.82:46446 [24/Jul/2015:13:25:09.154] www webserver_8001/webhost01_8001 43/0/0/1/44 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:09 localhost haproxy[11452]: 115.236.160.82:46447 [24/Jul/2015:13:25:09.392] www webserver_8001/webhost02_8001 72/0/0/1/73 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:09 localhost haproxy[11452]: 115.236.160.82:46448 [24/Jul/2015:13:25:09.728] www webserver_8001/webhost01_8001 41/0/1/1/43 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:10 localhost haproxy[11452]: 115.236.160.82:46449 [24/Jul/2015:13:25:09.978] www webserver_8001/webhost02_8001 58/0/0/1/59 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:10 localhost haproxy[11504]: 115.236.160.82:46450 [24/Jul/2015:13:25:10.230] www www/<NOSRV> 46/-1/-1/-1/46 302 126 - - LR-- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:11 localhost haproxy[11504]: 115.236.160.82:46453 [24/Jul/2015:13:25:11.180] www www/<NOSRV> 70/-1/-1/-1/70 302 126 - - LR-- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:11 localhost haproxy[11452]: 115.236.160.82:46455 [24/Jul/2015:13:25:11.607] www webserver_8001/webhost01_8001 46/0/1/0/47 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:11 localhost haproxy[11504]: 115.236.160.82:46456 [24/Jul/2015:13:25:11.888] www www/<NOSRV> 75/-1/-1/-1/75 302 126 - - LR-- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:12 localhost haproxy[11504]: 218.92.227.165:41490 [24/Jul/2015:13:25:12.047] www~ webserver_8001/webhost01_8001 86/0/1/0/88 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:12 localhost haproxy[11504]: 115.236.160.82:46458 [24/Jul/2015:13:25:12.367] www www/<NOSRV> 40/-1/-1/-1/40 302 126 - - LR-- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:12 localhost haproxy[11452]: 115.236.160.82:46460 [24/Jul/2015:13:25:12.765] www webserver_8001/webhost02_8001 57/0/1/1/59 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:13 localhost haproxy[11452]: 115.236.160.82:46461 [24/Jul/2015:13:25:13.050] www webserver_8001/webhost01_8001 62/0/0/1/63 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:13 localhost haproxy[11452]: 115.236.160.82:46462 [24/Jul/2015:13:25:13.292] www webserver_8001/webhost02_8001 78/0/1/2/81 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:13 localhost haproxy[11452]: 115.236.160.82:46463 [24/Jul/2015:13:25:13.593] www webserver_8001/webhost01_8001 77/0/1/1/79 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:13 localhost haproxy[11504]: 115.236.160.82:46464 [24/Jul/2015:13:25:13.893] www www/<NOSRV> 41/-1/-1/-1/41 302 126 - - LR-- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    Jul 24 13:25:17 localhost haproxy[11504]: 219.217.227.93:58576 [24/Jul/2015:13:25:15.385] www~ webserver_8001/webhost02_8001 2440/0/1/0/2442 200 14233 - - ---- 0/0/0/0/0 0/0 "GET / HTTP/1.1"
    
    

  • 相关阅读:
    Linux strace命令使用详解
    Ubuntu 给应用程序添加桌面图标(本文以Eclipse为例)
    Linux(Ubuntu/Debian/CentOS/RedHat)下交叉编译boost库
    Ubuntu下安装RabbbitVCS(图形化svn管理工具)- Ubuntu也有TortoiseSVN
    Linux下编译C++程序遇到错误:undefined reference to `*::*
    Linux系统(Ubuntu/Debian/RedHat/CentOS)超级简单的samba配置文件smb.conf
    Makefile常用万能模板(包括静态链接库、动态链接库、可执行文件)
    Ubuntu/Debian交叉编译安装ARM平台版本的ffmpeg
    apue编程之参考du代码利用递归写的一个简单的du命令的源代码
    linux 编译kernel与svn版本冲突解决方法 [drivers/gpu/mali/mali/common/mali_kernel_core.o] 错误 1
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351510.html
Copyright © 2011-2022 走看看