.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::HTML5::Parser::UA 3pm" .TH HTML::HTML5::Parser::UA 3pm "2022-08-28" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" HTML::HTML5::Parser::UA \- simple web user agent class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use aliased \*(AqHTML::HTML5::Parser::UA\*(Aq; \& \& my $response = UA\->get($url); \& die unless $response\->{success}; \& \& print $response\->{decoded_content}; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a simple wrapper around HTTP::Tiny and LWP::UserAgent to smooth out the \s-1API\s0 differences between them. It only supports bog standard \&\f(CW\*(C`get($url)\*(C'\fR requests. .PP If LWP::UserAgent is already in memory, this module will use that. .PP If LWP::UserAgent is not in memory, then this module will use HTTP::Tiny (or direct filesystem access for \*(L"file://\*(R" URLs). .PP If LWP::UserAgent is not in memory, and you attempt to request a \s-1URL\s0 that HTTP::Tiny cannot handle (e.g. an \*(L"ftp://\*(R" \s-1URL\s0), then this module will load LWP::UserAgent and die if it cannot be loaded (e.g. is not installed). .PP HTML::HTML5::Parser::UA is used by the \f(CW\*(C`parse_file\*(C'\fR method of HTML::HTML5::Parser. .SS "Class Method" .IX Subsection "Class Method" .ie n .IP """get($url, $ua)""" 4 .el .IP "\f(CWget($url, $ua)\fR" 4 .IX Item "get($url, $ua)" Gets the \s-1URL\s0 and returns a hashref similar to HTTP::Tiny's hashrefs, but with an additional \f(CW\*(C`decoded_content\*(C'\fR key, which contains the response body, decoded into a Perl character string (not a byte string). .Sp If \f(CW$ua\fR is given (it's optional), then this user agent will be used to perform the actual request. Must be undef or an LWP::UserAgent object (or a subclass) or an HTTP::Tiny object (or a subclass). .SS "Package Variable" .IX Subsection "Package Variable" .ie n .IP "$HTML::HTML5::Parser::NO_LWP" 4 .el .IP "\f(CW$HTML::HTML5::Parser::NO_LWP\fR" 4 .IX Item "$HTML::HTML5::Parser::NO_LWP" If true, avoids using LWP::UserAgent. .SH "MOTIVATION" .IX Header "MOTIVATION" LWP::UserAgent is a good piece of software but it has a dependency on HTML::Parser. HTML::Parser is only used to provide one fairly esoteric feature, which this package doesn't make use of. (It's the \&\f(CW\*(C`parse_head\*(C'\fR option.) .PP Because of that, I don't especially want HTML::HTML5::Parser to have a dependency on LWP::UserAgent. Hence this module. .SH "SEE ALSO" .IX Header "SEE ALSO" HTML::HTML5::Parser. .SH "AUTHOR" .IX Header "AUTHOR" Toby Inkster, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2012 by Toby Inkster .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "DISCLAIMER OF WARRANTIES" .IX Header "DISCLAIMER OF WARRANTIES" \&\s-1THIS PACKAGE IS PROVIDED \*(L"AS IS\*(R" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\s0