[英]Perl - WWW::Mechanize not working with proxy
Machine: Windows 7 Professional 64 bit. 机器:Windows 7 Professional 64位。 Portable Perl (Strawberry Perl (64-bit) 5.22.0.1).
便携式Perl(Strawberry Perl(64位)5.22.0.1)。
Proxy settings in Internet Explorer. Internet Explorer中的代理设置。
- Automatically detect settings - 自动检测设置
- use automatic configuration script - 使用自动配置脚本
- Address : http://url:portno/proxy.pac - 地址: http:// url:portno / proxy.pac
With below code, I am not able to get proper response. 使用以下代码,我无法得到正确的答复。
use strict;
use warnings;
use WWW::Mechanize;
use LWP::UserAgent;
use LWP::Protocol::https;
print LWP::UserAgent->VERSION, "\n";
print LWP::Protocol::https->VERSION, "\n";
#$ENV{HTTPS_PROXY} = 'http://url:portno/proxy.pac';
#$objMech->get("http://www.url.html");
my $objMech = WWW::Mechanize->new(autocheck => 0 );
$objMech->proxy(['https', 'http', 'ftp'], 'http://url:portno/proxy.pac');
$objMech->get("http://www.url.com");
print $objMech->content();
my @links = $objMech->links();
for my $link (@links) {
printf $link->text, $link->url;
}
It's output is as follows: 它的输出如下:
6.13
6.06
<HTML>
<Head>
<TITLE>400 Bad Request
</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF"><h1>
400 Bad Request
</h1>
</BODY>
</HTML>
$objMech->proxy(['https', 'http', 'ftp'], 'http://url:portno/proxy.pac');
You have to give the URL of the proxy itself (ie http://ip:port
) and not the URL were a proxy configuration script is located (ie the PAC file). 您必须提供代理本身的URL(即
http://ip:port
),而不是URL是代理配置脚本(即PAC文件)。 These PAC files are Javascript code which returns the appropriate proxy URL based on the target URL. 这些PAC文件是Javascript代码,它根据目标URL返回相应的代理URL。 LWP/WWW::Mechanize does not support Javascript and can not deal with such proxy configuration files by itself.
LWP / WWW :: Mechanize不支持Javascript,也不能单独处理这样的代理配置文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.