简体   繁体   English

Perl WWW ::机械化并通过身份验证的代理

[英]Perl WWW::Mechanize and authenticated proxy

I have a proxy with IP, Port, Login and Password. 我有一个具有IP,端口,登录名和密码的代理。 Is it possible to use this proxy with Perl's WWW::Mechanize ? 是否可以将此代理与Perl的WWW :: Mechanize一起使用

Thanks. 谢谢。

  1. I'm not sure if there's a native way but here's a workaround which is claimed to work: 我不确定是否有本机方法,但是这是一种可行的解决方法:

    http://www.perlmonks.org/?node_id=269358 http://www.perlmonks.org/?node_id=269358

    It's based on setting $ENV{HTTP_PROXY} to " http://login:password@proxyserver " where both login and password must be URI-encoded. 它基于将$ENV{HTTP_PROXY}设置$ENV{HTTP_PROXY}http:// login:password @ proxyserver ”,其中,登录名和密码都必须使用URI编码。

  2. Also, WWW::Mechanize is a subclass of LWP::UserAgent , and as such, what works in LWP should work on Mechanize (example from LWP Cookbook, PROXIES section ) 另外,WWW :: Mechanize是LWP::UserAgent的子类,因此,在LWP中有效的方法应在Mechanize上起作用(例如,来自LWP Cookbook的PROXIES部分

     use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->proxy(['http', 'ftp'] => 'http://username:password@proxy.myorg.com'); $req = HTTP::Request->new('GET',"http://www.perl.com"); $res = $ua->request($req); print $res->decoded_content if $res->is_success; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM