The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HtmlUnit - Inline::Java based wrapper of the HtmlUnit library

SYNOPSIS

use HtmlUnit;
my $webClient = HtmlUnit->new('FIREFOX_3');
my $page = $webClient->getPage("http://google.com/");
my $f = $page->getFormByName('f');
my $submit = $f->getInputByName("btnG");
my $query  = $f->getInputByName("q");
$page = $query->type("HtmlUnit");
$page = $query->type("\n");

my $content = $page->asXml;
print "Result:\n$content\n\n";

DESCRIPTION

This is a wrapper around the HtmlUnit library. It includes the HtmlUnit jar itself and it's dependencies. All this library really does is find the jars and load them up using Inline::Java.

The reason all this is interesting? HtmlUnit has very good javascript support, so you can automate, scrape, or test javascript-required websites.

METHODS

$webClient = HtmlUnit->new($browser_name)

This is just a shortcut for

$webClient = HtmlUnit::com::gargoylesoftware::htmlunit::WebClient->new;

The optional $browser_name allows you to specify which browser version to pass to the WebClient->new method.

SEE ALSO

http://htmlunit.sourceforge.net/, Inline::Java

AUTHOR

Brock Wilcox <awwaiid@thelackthereof.org> - http://thelackthereof.org/

COPYRIGHT

Copyright (c) 2008 Brock Wilcox <awwaiid@thelackthereof.org>. All rights
reserved.  This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

HtmlUnit library includes the following copyright:

    Copyright (c) 2002-2008 Gargoyle Software Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.