--
Zhengquan Zhang,
group: 201.557.6880
work: 201.239.2238
Electronic Trading Group
Knight Capital Americas L.P.
On Wed, Dec 28, 2011 at 11:14:00AM -0500, Brock Wilcox via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=73535 >
>
>
>
> On 2011.12.28.11.01, Zhang, Zhengquan via RT wrote:
> > here my test.pl:
> >
> > use strict;
> > use warnings;
> >
> > use WWW::HtmlUnit;
> > use Inline::Java qw(study_classes);
> >
> > study_classes(['com.gargoylesoftware.htmlunit.ProxyConfig'], 'WWW::HtmlUnit');
> >
> > my $proxy_config =
> > WWW::HtmlUnit::com::gargoylesoftware::htmlunit::ProxyConfig->new(
> > '
http://statarb:sT4tArB@jc1prxy2',
> > 8080,
> > );
>
> Took a gander at the internet docs for HtmlUnit, and was surprised that
> the 'http://' part actually looks valid (I thought you didn't need it).
> I think you can set the user/password like this, but I'm not sure:
>
> my $credentials = $webClient->getCredentialsProvider;
> $credentials->addProxyCredentials($username, $password);
>
> > my $webClient = WWW::HtmlUnit->new;
> > webClient->setProxyConfig($proxy_config);
>
> This won't compile because it should be:
>
> $webClient->setProxyConfig($proxy_config);
>
> (I forgot the '$' :) ). I tested this and it at least compiles now,
> though I don't have a proxy set up to actually test beyond that.
stupid me missed the $ as well:)
now I get another compile error in setting the username and password.
perl test.pl
Global symbol "$webclient" requires explicit package name at test.pl line 39,
<GEN6> line 4.
Execution of test.pl aborted due to compilation errors.
test.pl:
use strict;
use warnings;
use WWW::HtmlUnit;
use Inline::Java qw(study_classes);
study_classes(['com.gargoylesoftware.htmlunit.ProxyConfig'], 'WWW::HtmlUnit');
my $proxy_config =
WWW::HtmlUnit::com::gargoylesoftware::htmlunit::ProxyConfig->new(
'
http://statarb:sT4tArB@jc1prxy2',
8080,
);
my $webClient = WWW::HtmlUnit->new;
$webClient->setProxyConfig($proxy_config);
my ($username,$password)= ('statarb', 'sT4tArB');
my $credentialsProvider = $webclient->getCredentialsProvider();
$credentialsProvider->addProxyCredentials($username, $password);
my $page = $webClient->getPage( "
http://htmlunit.sourceforge.net",);
print $page->getTitleText();
Thanks.
Jim
Please visit our website for important disclaimers/disclosures regarding Knight’s products and services:
http://knight.com/KnightEmailDisclaimer.html