HTML::...ser::UA(3pm)
π NAME π
HTML::HTML5::Parser::UA β a simple web user agent class, bestie. That's it, that's the vibe. π¦
β¨ SYNOPSIS β¨
use aliased 'HTML::HTML5::Parser::UA';
my $response = UA->get($url);
die unless $response->{success};
print $response->{decoded_content};
look at her go. iconic behavior. π
πΈ DESCRIPTION πΈ
okay so real talk, this whole thing is a simple wrapper sitting on top of HTTP::Tiny and LWP::UserAgent, and its entire job is to smooth out the API differences between the two so you don't have to deal with their little personality clashes. that's it. she's a mediator. no cap.
she only supports bog standard get($url) requests. nothing fancy. we're not doing POSTs today, bestie. π
here's the tea on how she picks her engine:
- If
LWP::UserAgentis already in memory, this module will use that. periodt. - If
LWP::UserAgentis not in memory, then this module will useHTTP::Tiny(or direct filesystem access forfile://URLs β yes, she'll just read the file off disk like it's nothing π). - If
LWP::UserAgentis not in memory, and you attempt to request a URL thatHTTP::Tinycannot handle (e.g. anftp://URL), then this module will loadLWP::UserAgentand die if it cannot be loaded (e.g. is not installed). so like, she'll try, but if LWP isn't installed? π she's gone.
also psa: HTML::HTML5::Parser::UA is used by the parse_file method of HTML::HTML5::Parser. iykyk. π
π Class Method π
get($url, $ua)β gets the URL and returns a hashref similar toHTTP::Tiny's hashrefs, but with an additionaldecoded_contentkey, which contains the response body, decoded into a Perl character string (not a byte string). that's the little glow-up she brings to the table, and honestly? she ate. β¨
if $ua is given (it's optional, no pressure π), then this user agent will be used to perform the actual request. it must be undef or an LWP::UserAgent object (or a subclass) or an HTTP::Tiny object (or a subclass). no random objects, bestie, she has standards. π
π Package Variable π
$HTML::HTML5::Parser::NO_LWPβ if true, avoids usingLWP::UserAgent. she'll stay in herHTTP::Tinylane. π¦
π MOTIVATION π
okay so here's the lore. LWP::UserAgent is genuinely a good piece of software β no shade, she's a queen π β but she has a dependency on HTML::Parser. and HTML::Parser is only used to provide one fairly esoteric feature, which this package doesn't make use of.
which feature? it's the parse_head option. that's the whole reason. π
because of that, i don't especially want HTML::HTML5::Parser to have a dependency on LWP::UserAgent. hence this module. problem solved, slay. π
β SEE ALSO β
- HTML::HTML5::Parser.
π«Ά AUTHOR π«Ά
Toby Inkster, <tobyink@cpan.org> β legend behavior. π
π COPYRIGHT AND LICENSE π
Copyright (C) 2012 by Toby Inkster
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. free as in freedom bestie π
π DISCLAIMER OF WARRANTIES π
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
fr fr, she is not liable. read that again. π
and that's the whole page!! mwah π this doc shipped with perl v5.36.0 and got its glow-up dated 2022-08-28 β go forth and get($url) responsibly, bestie. π¦β¨
π¦ where this page comes from
- ubuntu noble: libhtml-html5-parser-perl 0.992-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-html5-parser-perl 0.992-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-html5-parser-perl 0.992-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms