Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

It is all about getting through the proxy @work. I have no luck with LWP::UserAgent in our network.

In R, you can use setinternet2(true) for this: I had to remove the links to r-bloggers.com, it was considered a spam site :-) - and it "just works" (no need to type in name and password) but just in R. The description of the function: By typing setInternet2(TRUE), R connects via internet2.dll, which Internet Explorer uses. From a network point of view this makes R appear to be the same as Internet Explorer, and sneak through.

Is there an equivalent to this function in Perl?

Thank you and I do hope this is not an OT.

Replies are listed 'Best First'.
Re: (Is there ) Perl equivalent to setinternet2(true) in R ?
by mr_mischief (Monsignor) on Sep 04, 2014 at 13:51 UTC

    Is this proxy filtering based on user agent or on program, or do you just need to configure the software to use the proxy?

    There's the agent() method for LWP::UserAgent. It doesn't wrap a specific Windows DLL but it does allow you to set your UserAgent string to whatever you want.

    If you just need to configure your user agent to use the proxy, there are proxy attributes for LWP::UserAgent, too.

    There's WWW::Selenium which is designed to test things using the Selenium suite (see also Alien::Selenium). That uses Firefox or IE to connect and retrieve pages. A quick search of CPAN also shows a few modules I've never used that may help by actually using Internet Explorer to access things.:

    See also WWW::Mechanize

      Thank you very much! It seems that one need to configure software to use the proxy.

      I tried the following:

      use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->env_proxy; my $req = HTTP::Request->new(GET => 'http://www.perlmonks.org'); print $ua->request($req)->as_string;

      This made no connection @work (I am @home now, sorry, cannot reproduce the exact error message). The attempt with $ua->proxy($scheme, $proxy_url) "did not work" either - again, cannot reproduce the exact error message till tomorrow but it did not ask to type in a password or something.

      I'll definitely give Win32::IEAutomation a try.

      WWW::Selenium requires that Selenium Server is installed - not an option here ...