HTTPS Proxy and LWP::UserAgent

后端 未结 8 2032
说谎
说谎 2020-12-17 02:18

I have read a number of threads on a number of sites and am still unable to make this work.

I have a client machine (OSX) with OpenSSL 0.9.8r running perl 5.12.4, w

相关标签:
8条回答
  • 2020-12-17 03:03

    I just uploaded the LWP::Protocol::connect module to CPAN. This module adds the missing HTTP/CONNECT method support to LWP.

      use LWP::UserAgent;
    
      $ua = LWP::UserAgent->new(); 
      $ua->proxy('https', 'connect://proxyhost.domain:3128/');
    
      $ua->get('https://www.somesslsite.com');
    

    With this module you can use the regular IO::Socket::SSL implementation for LWP >=6.00.

    0 讨论(0)
  • 2020-12-17 03:04

    #!/usr/bin/env perl 
    # 
    # mimvp.com
    # 2017-03-28
    
    use CGI;
    use strict;
    use LWP::UserAgent;
    
    
    our %proxy_https = ("https", "connect://173.233.55.118:443");
    our $mimvp_url = "https://proxy.mimvp.com/exist.php";
    
    ## https
    ## 1. download LWP-Protocol-connect (wget http://search.cpan.org/CPAN/authors/id/B/BE/BENNING/LWP-Protocol-connect-6.09.tar.gz)
    ## 2. tar zxvf LWP-Protocol-connect-6.09.tar.gz 
    ##    cd LWP-Protocol-connect-6.09
    ##    perl Makefile.PL
    ##    make
    ##    sudo make install
    sub test_connect {
    	my ($url, %proxy) = @_;
    	
    	print "proxy  : $proxy{'http'}\n";
    	print "https  : $proxy{'https'}\n";
    	print "socks4 : $proxy{'socks4'}\n";
    	print "socks5 : $proxy{'socks5'}\n";
    	print "url : $url\n";
    	
    	my $browser = LWP::UserAgent->new();
    	$browser->env_proxy();
    	
    # 	# 设置的代理格式
    	$browser->proxy(%proxy);
    	$browser->timeout(30);
    	$browser->agent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36');
    	
    # 	my $req = new HTTP::Request('GET', $url);
    # 	my $response = $browser->request($req);
    	my $response = $browser->get($url);  				# 爬取的网址
    	my $is_success = $response->is_success();			# 1
    	my $content_type = $response->content_type();		# text/html
    	my $content = $response->content();					# 网页正文
    	my $content_length = length($content);				# 网页正文长度
    	
    	print "$is_success\n";
    	print "$content_type\n";
    	print "$content_length\n";
    	print "$content\n";
    }
    
    test_connect($mimvp_url, %proxy_https);		# https
    
    ## perl mimvp-proxy-perl.pl

    0 讨论(0)
提交回复
热议问题