1HTML::HTML5::Parser::UAU(s3e)r Contributed Perl DocumentaHtTiMoLn::HTML5::Parser::UA(3)
2
3
4

NAME

6       HTML::HTML5::Parser::UA - simple web user agent class
7

SYNOPSIS

9        use aliased 'HTML::HTML5::Parser::UA';
10
11        my $response = UA->get($url);
12        die unless $response->{success};
13
14        print $response->{decoded_content};
15

DESCRIPTION

17       This is a simple wrapper around HTTP::Tiny and LWP::UserAgent to smooth
18       out the API differences between them. It only supports bog standard
19       "get($url)" requests.
20
21       If LWP::UserAgent is already in memory, this module will use that.
22
23       If LWP::UserAgent is not in memory, then this module will use
24       HTTP::Tiny (or direct filesystem access for "file://" URLs).
25
26       If LWP::UserAgent is not in memory, and you attempt to request a URL
27       that HTTP::Tiny cannot handle (e.g. an "ftp://" URL), then this module
28       will load LWP::UserAgent and die if it cannot be loaded (e.g. is not
29       installed).
30
31       HTML::HTML5::Parser::UA is used by the "parse_file" method of
32       HTML::HTML5::Parser.
33
34   Class Method
35       "get($url, $ua)"
36           Gets the URL and returns a hashref similar to HTTP::Tiny's
37           hashrefs, but with an additional "decoded_content" key, which
38           contains the response body, decoded into a Perl character string
39           (not a byte string).
40
41           If $ua is given (it's optional), then this user agent will be used
42           to perform the actual request. Must be undef or an LWP::UserAgent
43           object (or a subclass) or an HTTP::Tiny object (or a subclass).
44
45   Package Variable
46       $HTML::HTML5::Parser::NO_LWP
47           If true, avoids using LWP::UserAgent.
48

MOTIVATION

50       LWP::UserAgent is a good piece of software but it has a dependency on
51       HTML::Parser. HTML::Parser is only used to provide one fairly esoteric
52       feature, which this package doesn't make use of. (It's the "parse_head"
53       option.)
54
55       Because of that, I don't especially want HTML::HTML5::Parser to have a
56       dependency on LWP::UserAgent. Hence this module.
57

SEE ALSO

59       HTML::HTML5::Parser.
60

AUTHOR

62       Toby Inkster, <tobyink@cpan.org>
63
65       Copyright (C) 2012 by Toby Inkster
66
67       This library is free software; you can redistribute it and/or modify it
68       under the same terms as Perl itself.
69

DISCLAIMER OF WARRANTIES

71       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
72       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
73       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
74
75
76
77perl v5.30.0                      2019-07-26        HTML::HTML5::Parser::UA(3)
Impressum