Crawl4AI/Client.pm

filter: Statementstmt 80.8% 236 / 292 Branchbran 52.1% 74 / 142 Conditioncond 31.4% 44 / 140 MC/DCmcdc 11.8% 9 / 76 Subroutinesub 80.8% 59 / 73 Podpod 100% 35 / 35 totaltotal 60.2% 457 / 758 CC 123 SCAR 26.9
CC
123
Cov
62%
parse_job_status_response
93.4
_result_list
37.1
_normalize_page
29.1
CRAP 14.7
↑ Summary Crawl4AI/Detect.pm »
1 package WWW::Crawl4AI::Client;
2 # ABSTRACT: UA-agnostic REST client for the Crawl4AI Docker API
3 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use HTTP::Request ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use LWP::UserAgent ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use URI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use URI::Escape ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use MIME::Base64 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use WWW::Crawl4AI::Markdown qw( resolve_markdown_chain );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use WWW::Crawl4AI::Request ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use WWW::Crawl4AI::Error ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 12 our $VERSION = '0.001';
17  
18  
19 has base_url => (
20 is => 'ro',
21 0 ▶ default => sub { $ENV{CRAWL4AI_URL} || $ENV{CRAWL4AI_BASE_URL} || 'http://localhost:11235' },
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"CRAWL4AI_URL"} or $ENV{"CRAWL4AI_BASE_URL"} or "http://localhost:11235" 0 0 0
Condition0%0/3
$ENV{"CRAWL4AI_URL"} or $ENV{"CRAWL4AI_BASE_URL"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{"CRAWL4AI_URL"} or $ENV{"CRAWL4AI_BASE_URL"}
$ENV{"CRAWL4AI_URL"} $ENV{"CRAWL4AI_BASE_URL"}
Truth table0%0/3
A or B
A= $ENV{"CRAWL4AI_URL"}B= $ENV{"CRAWL4AI_BASE_URL"}
ABresult
1X1
011
000
22 12 );
23  
24  
25 has api_token => (
26 is => 'ro',
27 8 ▶ default => sub { $ENV{CRAWL4AI_API_TOKEN} },
Subroutine __ANON__: called CC=1 SCAR=0.0
28 12 );
29  
30  
31 has _json => (
32 is => 'lazy',
33 7 ▶ default => sub { JSON::MaybeXS->new( utf8 => 1, canonical => 1, convert_blessed => 1 ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
34 12 );
35  
36 has user_agent_string => (
37 is => 'ro',
38 13 ▶ default => sub { "WWW-Crawl4AI/$VERSION" },
Subroutine __ANON__: called CC=1 SCAR=0.0
39 12 );
40  
41  
42 13 ▶has timeout => ( is => 'ro', default => sub { 120 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
43  
44  
45 12 has ua => ( is => 'lazy' );
46  
47  
48 7 ▶has max_attempts => ( is => 'ro', default => sub { 3 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
49  
50  
51 7 ▶has retry_backoff => ( is => 'ro', default => sub { [ 1, 2, 4 ] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
52  
53  
54 13 ▶has retry_statuses => ( is => 'ro', default => sub { [ 429, 502, 503, 504 ] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
55  
56  
57 12 has on_retry => ( is => 'ro' );
58  
59  
60 has sleep_sub => (
61 is => 'ro',
62 7 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.4
63 7 require Time::HiRes;
64 0 ▶ return sub { Time::HiRes::sleep( $_[0] ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
65 },
66 12 );
67  
68  
69 12 has _retry_status_set => ( is => 'lazy' );
70 3 ▶sub _build__retry_status_set {
Subroutine _build__retry_status_set: called CC=1 SCAR=0.0
71 3 return { map { $_ => 1 } @{ $_[0]->retry_statuses } };
72 }
73  
74 1 ▶sub _build_ua {
Subroutine _build_ua: called CC=1 SCAR=0.0
75 1 my ( $self ) = @_;
76 1 return LWP::UserAgent->new(
77 agent => $self->user_agent_string,
78 timeout => $self->timeout,
79 # A redirect would carry the bearer token to a foreign host - refuse them.
80 max_redirect => 0,
81 );
82 }
83  
84 5 ▶sub is_request { $_[1]->$_isa('HTTP::Request') }
Subroutine is_request: called CC=1 SCAR=0.0
Pod documented
85  
86  
87 23 ▶sub _uri {
Subroutine _uri: called CC=1 SCAR=0.0
88 23 my ( $self, $path ) = @_;
89 23 ( my $base = $self->base_url ) =~ s{/+$}{};
90 23 return URI->new( $base . $path );
91 }
92  
93 23 ▶sub _request {
Subroutine _request: called CC=3 SCAR=11.0
94 23 my ( $self, $method, $path, $body ) = @_;
95 23 my $req = HTTP::Request->new( $method => $self->_uri($path) );
96 23 $req->header( Accept => 'application/json' );
97 23 ▶ $req->header( Authorization => 'Bearer ' . $self->api_token ) if defined $self->api_token;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->api_token 8 15 23
98 23 ▶ if ( defined $body ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $body) 14 9 23
99 14 $req->header( 'Content-Type' => 'application/json' );
100 14 $req->content( $self->_json->encode($body) );
101 }
102 23 return $req;
103 }
104  
105 #----------------------------------------------------------------------
106 # Request builders (no I/O)
107 #----------------------------------------------------------------------
108  
109 4 ▶sub crawl_request {
Subroutine crawl_request: called CC=1 SCAR=0.0
Pod documented
110 4 my ( $self, $request ) = @_;
111 4 return $self->_request( POST => '/crawl', $self->_payload( $request, 'to_crawl_payload' ) );
112 }
113  
114  
115 0 ▶sub md_request {
Subroutine md_request: not called CC=1 SCAR=6.9
Pod documented
116 0 my ( $self, $request ) = @_;
117 0 return $self->_request( POST => '/md', $self->_payload( $request, 'to_md_payload' ) );
118 }
119  
120 1 ▶sub job_submit_request {
Subroutine job_submit_request: called CC=1 SCAR=0.0
Pod documented
121 1 my ( $self, $request ) = @_;
122 1 return $self->_request( POST => '/crawl/job', $self->_payload( $request, 'to_crawl_payload' ) );
123 }
124  
125 5 ▶sub job_status_request {
Subroutine job_status_request: called CC=3 SCAR=12.0
Pod documented
126 5 my ( $self, $task_id ) = @_;
127 5 ▶ croak "job_status_request needs a task_id" unless defined $task_id && length $task_id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $task_id and length $task_id 0 5 5
Condition33%1/3
defined $task_id and length $task_id
!ll&&!rl&&r
005
MC/DC0%0/2
defined $task_id and length $task_id
defined $task_id length $task_id
Truth table33%1/3
A and B
A= defined $task_idB= length $task_id
ABresult
0X0
100
111
128 # The task id is one path segment: encode it, so it cannot address another
129 # endpoint and cannot split path and query.
130 5 my $segment = URI::Escape::uri_escape_utf8($task_id);
131 5 return $self->_request( GET => '/crawl/job/' . $segment );
132 }
133  
134 3 ▶sub health_request { $_[0]->_request( GET => '/health' ) }
Subroutine health_request: called CC=1 SCAR=0.0
Pod documented
135  
136 2 ▶sub screenshot_request {
Subroutine screenshot_request: called CC=7 SCAR=20.0
Pod documented
137 2 my ( $self, $url, %opts ) = @_;
138 2 ▶ croak "screenshot_request needs a url" unless defined $url && length $url;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $url and length $url 0 2 2
Condition33%1/3
defined $url and length $url
!ll&&!rl&&r
002
MC/DC0%0/2
defined $url and length $url
defined $url length $url
Truth table33%1/3
A and B
A= defined $urlB= length $url
ABresult
0X0
100
111
139 2 my %body = ( url => $url );
140 2 ▶ $body{screenshot_wait_for} = $opts{wait_for} if defined $opts{wait_for};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"wait_for"} 1 1 2
141 2 ▶ $body{output_path} = $opts{output_path} if defined $opts{output_path};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"output_path"} 1 1 2
142 $body{wait_for_images} =
143 $opts{wait_for_images} ? WWW::Crawl4AI::Request::JSON_true() : WWW::Crawl4AI::Request::JSON_false()
144 2 ▶ if exists $opts{wait_for_images};
Branch: 2 branches
BranchTrueFalseTotal
if exists $opts{"wait_for_images"} 1 1 2
$opts{'wait_for_images'} ? : 1 0 1
145 2 return $self->_request( POST => '/screenshot', \%body );
146 }
147  
148  
149 1 ▶sub pdf_request {
Subroutine pdf_request: called CC=4 SCAR=15.2
Pod documented
150 1 my ( $self, $url, %opts ) = @_;
151 1 ▶ croak "pdf_request needs a url" unless defined $url && length $url;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $url and length $url 0 1 1
Condition33%1/3
defined $url and length $url
!ll&&!rl&&r
001
MC/DC0%0/2
defined $url and length $url
defined $url length $url
Truth table33%1/3
A and B
A= defined $urlB= length $url
ABresult
0X0
100
111
152 1 my %body = ( url => $url );
153 1 ▶ $body{output_path} = $opts{output_path} if defined $opts{output_path};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"output_path"} 1 0 1
154 1 return $self->_request( POST => '/pdf', \%body );
155 }
156  
157 3 ▶sub html_request {
Subroutine html_request: called CC=3 SCAR=12.5
Pod documented
158 3 my ( $self, $url ) = @_;
159 3 ▶ croak "html_request needs a url" unless defined $url && length $url;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $url and length $url 0 3 3
Condition33%1/3
defined $url and length $url
!ll&&!rl&&r
003
MC/DC0%0/2
defined $url and length $url
defined $url length $url
Truth table33%1/3
A and B
A= defined $urlB= length $url
ABresult
0X0
100
111
160 3 return $self->_request( POST => '/html', { url => $url } );
161 }
162  
163 4 ▶sub execute_js_request {
Subroutine execute_js_request: called CC=6 SCAR=18.2
Pod documented
164 4 my ( $self, $url, $scripts ) = @_;
165 4 ▶ croak "execute_js_request needs a url" unless defined $url && length $url;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $url and length $url 0 4 4
Condition33%1/3
defined $url and length $url
!ll&&!rl&&r
004
MC/DC0%0/2
defined $url and length $url
defined $url length $url
Truth table33%1/3
A and B
A= defined $urlB= length $url
ABresult
0X0
100
111
166 4 ▶ $scripts = [$scripts] unless ref $scripts eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $scripts eq "ARRAY" 2 2 4
167 4 ▶ croak "execute_js_request needs at least one script" unless @$scripts && defined $scripts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless @$scripts and defined $scripts->[0] 2 2 4
Condition100%3/3
@$scripts and defined $scripts->[0]
!ll&&!rl&&r
112
MC/DC100%2/2
@$scripts and defined $scripts->[0]
@$scripts defined $scripts->[0]
Truth table100%3/3
A and B
A= @$scriptsB= defined $scripts->[0]
ABresult
0X0
100
111
168 2 return $self->_request( POST => '/execute_js', { url => $url, scripts => $scripts } );
169 }
170  
171 1 ▶sub llm_request {
Subroutine llm_request: called CC=8 SCAR=25.2
Pod documented
172 1 my ( $self, $url, $query, %opts ) = @_;
173 1 ▶ croak "llm_request needs a url" unless defined $url && length $url;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $url and length $url 0 1 1
Condition33%1/3
defined $url and length $url
!ll&&!rl&&r
001
MC/DC0%0/2
defined $url and length $url
defined $url length $url
Truth table33%1/3
A and B
A= defined $urlB= length $url
ABresult
0X0
100
111
174 1 ▶ croak "llm_request needs a query" unless defined $query && length $query;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $query and length $query 0 1 1
Condition33%1/3
defined $query and length $query
!ll&&!rl&&r
001
MC/DC0%0/2
defined $query and length $query
defined $query length $query
Truth table33%1/3
A and B
A= defined $queryB= length $query
ABresult
0X0
100
111
175 # The page URL is a path segment ({url:path}); escape it so its own scheme and
176 # query string don't merge into ours. The question and tuning go in the query.
177 1 my $path = URI->new( '/llm/' . URI::Escape::uri_escape_utf8($url) );
178 $path->query_form(
179 q => $query,
180 ( defined $opts{provider} ? ( provider => $opts{provider} ) : () ),
181 ( defined $opts{temperature} ? ( temperature => $opts{temperature} ) : () ),
182 1 ▶ ( defined $opts{base_url} ? ( base_url => $opts{base_url} ) : () ),
Branch: 3 branches
BranchTrueFalseTotal
defined $opts{'provider'} ? : 1 0 1
defined $opts{'temperature'} ? : 1 0 1
defined $opts{'base_url'} ? : 0 1 1
183 );
184 1 return $self->_request( GET => $path->as_string );
185 }
186  
187 1 ▶sub token_request {
Subroutine token_request: called CC=4 SCAR=15.2
Pod documented
188 1 my ( $self, $email, %opts ) = @_;
189 1 ▶ croak "token_request needs an email" unless defined $email && length $email;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $email and length $email 0 1 1
Condition33%1/3
defined $email and length $email
!ll&&!rl&&r
001
MC/DC0%0/2
defined $email and length $email
defined $email length $email
Truth table33%1/3
A and B
A= defined $emailB= length $email
ABresult
0X0
100
111
190 1 my %body = ( email => $email );
191 1 ▶ $body{api_token} = $opts{api_token} if defined $opts{api_token};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"api_token"} 0 1 1
192 1 return $self->_request( POST => '/token', \%body );
193 }
194  
195 5 ▶sub _payload {
Subroutine _payload: called CC=3 SCAR=11.4
196 5 my ( $self, $request, $method ) = @_;
197 5 ▶ return $request->$method if $request->$_isa('WWW::Crawl4AI::Request');
Branch: 1 branch
BranchTrueFalseTotal
if $request->$WWW::Crawl4AI::Client::_isa("WWW::Crawl4AI::Request") 4 1 5
198 1 ▶ return $request if ref $request eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $request eq "HASH" 1 0 1
199 0 croak "expected a WWW::Crawl4AI::Request or hashref payload";
200 }
201  
202 #----------------------------------------------------------------------
203 # Response parsers (no I/O)
204 #----------------------------------------------------------------------
205  
206 # The error text names status, method and path - never the token.
207 10 ▶sub _http_error_message {
Subroutine _http_error_message: called CC=5 SCAR=16.3
208 10 my ( $self, $res, $reason ) = @_;
209 10 my $where = '-';
210 10 my $req = $res->request;
211 10 ▶ if ($req) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req) 7 3 10
212 7 my $method = $req->method;
213 7 my $path = eval { $req->uri->path };
214 7 ▶ $path = '' unless defined $path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 0 7 7
215 7 ▶ $path = '/' unless length $path;
Branch: 1 branch
BranchTrueFalseTotal
unless length $path 0 7 7
216 7 ▶ $where = defined $method ? $method . ' ' . $path : $path;
Branch: 1 branch
BranchTrueFalseTotal
defined $method ? : 7 0 7
217 }
218 10 return 'Crawl4AI HTTP ' . $res->code . ': ' . $reason . ' (' . $where . ')';
219 }
220  
221 22 ▶sub _decode {
Subroutine _decode: called CC=8 SCAR=21.4
222 22 my ( $self, $res, $backend ) = @_;
223 22 my $code = $res->code;
224 22 ▶ my $body = $res->decoded_content // $res->content // '';
Condition40%2/5
($res->decoded_content // $res->content) // ""
l!l
220
$res->decoded_content // $res->content
l!l&&r!l&&!r
2200
MC/DC0%0/2
($res->decoded_content // $res->content) // ""
$res->decoded_content $res->content
Truth table33%1/3
A // B
A= $res->decoded_contentB= $res->content
ABresult
1X1
011
000
225 22 my $data;
226 my $json_error;
227 22 ▶ if ( length $body ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $body) 15 7 22
228 15 $data = eval { $self->_json->decode($body) };
229 15 $json_error = $@;
230 }
231 22 ▶ if ( !$res->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_success) 6 16 22
232 6 my $reason = $res->message;
233 6 ▶ $reason = 'error' unless defined $reason && length $reason;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reason and length $reason 0 6 6
Condition33%1/3
defined $reason and length $reason
!ll&&!rl&&r
006
MC/DC0%0/2
defined $reason and length $reason
defined $reason length $reason
Truth table33%1/3
A and B
A= defined $reasonB= length $reason
ABresult
0X0
100
111
234 6 die WWW::Crawl4AI::Error->new(
235 type => 'api',
236 message => $self->_http_error_message( $res, $reason ),
237 response => $res,
238 data => $data,
239 status_code => $code,
240 backend => $backend,
241 );
242 }
243 16 ▶ if ($json_error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($json_error) 4 12 16
244 4 die WWW::Crawl4AI::Error->new(
245 type => 'api',
246 message => $self->_http_error_message( $res, 'the answer was no JSON' ),
247 response => $res,
248 status_code => $code,
249 backend => $backend,
250 );
251 }
252 12 return $data;
253 }
254  
255 2 ▶sub parse_crawl_response {
Subroutine parse_crawl_response: called CC=1 SCAR=0.0
Pod documented
256 2 my ( $self, $res, $backend ) = @_;
257 2 my $data = $self->_decode( $res, $backend );
258 1 return [ map { $self->_normalize_page($_) } @{ $self->_result_list($data) } ];
259 }
260  
261  
262 1 ▶sub parse_md_response {
Subroutine parse_md_response: called CC=5 SCAR=30.6
Pod documented
263 1 my ( $self, $res, $backend ) = @_;
264 1 my $data = $self->_decode( $res, $backend );
265 0 ▶ return $data if !ref $data;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data 0 0 0
266 # /md commonly returns { markdown => ... } or { result => ... }
267 0 ▶ return $data->{markdown} // $data->{result} // $data->{md} // $data;
Condition0%0/9
(($data->{"markdown"} // $data->{"result"}) // $data->{"md"}) // $data
l!l&&r!l&&!r
000
($data->{"markdown"} // $data->{"result"}) // $data->{"md"}
l!l&&r!l&&!r
000
$data->{"markdown"} // $data->{"result"}
l!l&&r!l&&!r
000
MC/DC0%0/4
(($data->{"markdown"} // $data->{"result"}) // $data->{"md"}) // $data
$data->{"markdown"} $data->{"result"} $data->{"md"} $data
Truth table0%0/5
A // B // C // D
A= $data->{"markdown"}B= $data->{"result"}C= $data->{"md"}D= $data
ABCDresult
1XXX1
01XX1
001X1
00011
00000
268 }
269  
270 0 ▶sub parse_job_submit_response {
Subroutine parse_job_submit_response: not called CC=4 SCAR=30.0
Pod documented
271 0 my ( $self, $res, $backend ) = @_;
272 0 my $data = $self->_decode( $res, $backend );
273 0 ▶ my $id = $data->{task_id} // $data->{job_id} // $data->{id};
Condition0%0/6
($data->{"task_id"} // $data->{"job_id"}) // $data->{"id"}
l!l&&r!l&&!r
000
$data->{"task_id"} // $data->{"job_id"}
l!l&&r!l&&!r
000
MC/DC0%0/3
($data->{"task_id"} // $data->{"job_id"}) // $data->{"id"}
$data->{"task_id"} $data->{"job_id"} $data->{"id"}
Truth table0%0/4
A // B // C
A= $data->{"task_id"}B= $data->{"job_id"}C= $data->{"id"}
ABCresult
1XX1
01X1
0011
0000
274 0 ▶ croak "Crawl4AI job submit returned no task_id" unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
275 0 return { task_id => $id, raw => $data };
276 }
277  
278 3 ▶sub parse_job_status_response {
Subroutine parse_job_status_response: called CC=10 SCAR=45.4
Pod documented
279 3 my ( $self, $res, $backend ) = @_;
280 3 my $data = $self->_decode( $res, $backend );
281 0 ▶ my $status = uc( $data->{status} // $data->{state} // 'UNKNOWN' );
Condition0%0/5
($data->{"status"} // $data->{"state"}) // "UNKNOWN"
l!l
00
$data->{"status"} // $data->{"state"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($data->{"status"} // $data->{"state"}) // "UNKNOWN"
$data->{"status"} $data->{"state"}
Truth table0%0/3
A // B
A= $data->{"status"}B= $data->{"state"}
ABresult
1X1
011
000
282 0 my $pages;
283 0 ▶ if ( $status eq 'COMPLETED' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status eq "COMPLETED") 0 0 0
284 0 ▶ my $results = $data->{results} // $data->{result} // $data->{data};
Condition0%0/6
($data->{"results"} // $data->{"result"}) // $data->{"data"}
l!l&&r!l&&!r
000
$data->{"results"} // $data->{"result"}
l!l&&r!l&&!r
000
MC/DC0%0/3
($data->{"results"} // $data->{"result"}) // $data->{"data"}
$data->{"results"} $data->{"result"} $data->{"data"}
Truth table0%0/4
A // B // C
A= $data->{"results"}B= $data->{"result"}C= $data->{"data"}
ABCresult
1XX1
01X1
0011
0000
285 0 ▶ $pages = [ map { $self->_normalize_page($_) } @{ $self->_result_list($results) } ]
Branch: 1 branch
BranchTrueFalseTotal
if defined $results 0 0 0
286 if defined $results;
287 }
288 0 ▶ if ( $status eq 'FAILED' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status eq "FAILED") 0 0 0
289 die WWW::Crawl4AI::Error->new(
290 type => 'job',
291 0 ▶ message => "Crawl4AI job failed: " . ( $data->{error} // $data->{detail} // 'unknown' ),
Condition0%0/5
($data->{"error"} // $data->{"detail"}) // "unknown"
l!l
00
$data->{"error"} // $data->{"detail"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($data->{"error"} // $data->{"detail"}) // "unknown"
$data->{"error"} $data->{"detail"}
Truth table0%0/3
A // B
A= $data->{"error"}B= $data->{"detail"}
ABresult
1X1
011
000
292 data => $data,
293 backend => $backend,
294 );
295 }
296 0 return { status => $status, pages => $pages, raw => $data };
297 }
298  
299 7 ▶sub parse_health_response {
Subroutine parse_health_response: called CC=3 SCAR=11.0
Pod documented
300 7 my ( $self, $res ) = @_;
301 7 my $data = $self->_decode( $res, undef );
302 4 ▶ return 0 unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 2 2 4
303 2 ▶ return ref $data eq 'HASH' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'HASH' ? : 1 1 2
304 }
305  
306 2 ▶sub parse_screenshot_response {
Subroutine parse_screenshot_response: called CC=1 SCAR=0.0
Pod documented
307 2 my ( $self, $res, $backend ) = @_;
308 2 return $self->_decode_b64_artifact( $self->_decode( $res, $backend ), 'screenshot', $backend );
309 }
310  
311  
312 2 ▶sub parse_pdf_response {
Subroutine parse_pdf_response: called CC=1 SCAR=0.0
Pod documented
313 2 my ( $self, $res, $backend ) = @_;
314 2 return $self->_decode_b64_artifact( $self->_decode( $res, $backend ), 'pdf', $backend );
315 }
316  
317 # /screenshot and /pdf return { success => bool, <key> => base64 }. Decode to raw
318 # bytes; raise a content error if the server reported nothing usable.
319 3 ▶sub _decode_b64_artifact {
Subroutine _decode_b64_artifact: called CC=4 SCAR=14.0
320 3 my ( $self, $data, $key, $backend ) = @_;
321 3 ▶ my $b64 = ref $data eq 'HASH' ? $data->{$key} : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'HASH' ? : 3 0 3
322 3 ▶ unless ( defined $b64 && length $b64 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $b64 and length $b64) 1 2 3
Condition66%2/3
defined $b64 and length $b64
!ll&&!rl&&r
102
MC/DC50%1/2
defined $b64 and length $b64
defined $b64 length $b64
Truth table66%2/3
A and B
A= defined $b64B= length $b64
ABresult
0X0
100
111
323 1 die WWW::Crawl4AI::Error->new(
324 type => 'content',
325 message => "Crawl4AI returned no $key",
326 data => $data,
327 backend => $backend,
328 );
329 }
330 2 return MIME::Base64::decode_base64($b64);
331 }
332  
333 2 ▶sub parse_html_response {
Subroutine parse_html_response: called CC=2 SCAR=7.1
Pod documented
334 2 my ( $self, $res, $backend ) = @_;
335 2 my $data = $self->_decode( $res, $backend );
336 1 ▶ return ref $data eq 'HASH' ? $data->{html} : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'HASH' ? : 1 0 1
337 }
338  
339  
340 1 ▶sub parse_execute_js_response {
Subroutine parse_execute_js_response: called CC=3 SCAR=11.3
Pod documented
341 1 my ( $self, $res, $backend ) = @_;
342 1 my $data = $self->_decode( $res, $backend );
343 # /execute_js returns a single crawl result (same shape as one /crawl page)
344 # with the script output added under js_execution_result.
345 1 ▶ my $page = $self->_normalize_page( ref $data eq 'HASH' ? $data : { raw => $data } );
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'HASH' ? : 1 0 1
346 1 ▶ $page->{js_result} = ref $data eq 'HASH' ? $data->{js_execution_result} : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'HASH' ? : 1 0 1
347 1 return $page;
348 }
349  
350  
351 1 ▶sub parse_llm_response {
Subroutine parse_llm_response: called CC=4 SCAR=17.1
Pod documented
352 1 my ( $self, $res, $backend ) = @_;
353 1 my $data = $self->_decode( $res, $backend );
354 1 ▶ return ref $data eq 'HASH' ? ( $data->{answer} // $data->{result} // $data ) : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'HASH' ? : 1 0 1
Condition33%2/6
($data->{"answer"} // $data->{"result"}) // $data
l!l&&r!l&&!r
100
$data->{"answer"} // $data->{"result"}
l!l&&r!l&&!r
100
MC/DC0%0/3
($data->{"answer"} // $data->{"result"}) // $data
$data->{"answer"} $data->{"result"} $data
Truth table25%1/4
A // B // C
A= $data->{"answer"}B= $data->{"result"}C= $data
ABCresult
1XX1
01X1
0011
0000
355 }
356  
357  
358 1 ▶sub parse_token_response {
Subroutine parse_token_response: called CC=1 SCAR=0.0
Pod documented
359 1 my ( $self, $res, $backend ) = @_;
360 1 return $self->_decode( $res, $backend );
361 }
362  
363  
364 # Crawl4AI has returned the page list in several shapes across versions;
365 # accept all of them rather than pin to one.
366 1 ▶sub _result_list {
Subroutine _result_list: called CC=11 SCAR=36.1
367 1 my ( $self, $data ) = @_;
368 1 ▶ return [] unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 1 1
369 1 ▶ return $data if ref $data eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $data eq "ARRAY" 0 1 1
370 1 ▶ if ( ref $data eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "HASH") 1 0 1
371 1 for my $key (qw( results data result )) {
372 1 ▶ my $v = $data->{$key} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $v = $data->{$key} or next 1 0 1
373 1 ▶ return $v if ref $v eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "ARRAY" 1 0 1
374 0 ▶ return [$v] if ref $v eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "HASH" 0 0 0
375 }
376 # Looks like a single page itself.
377 0 ▶ return [$data] if exists $data->{markdown} || exists $data->{html} || exists $data->{success};
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"markdown"} or exists $data->{"html"} or exists $data->{"success"} 0 0 0
Condition0%0/6
exists $data->{"markdown"} or exists $data->{"html"} or exists $data->{"success"}
l!l&&r!l&&!r
000
exists $data->{"markdown"} or exists $data->{"html"}
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $data->{"markdown"} or exists $data->{"html"} or exists $data->{"success"}
exists $data->{"markdown"} exists $data->{"html"} exists $data->{"success"}
Truth table0%0/4
A or B or C
A= exists $data->{"markdown"}B= exists $data->{"html"}C= exists $data->{"success"}
ABCresult
1XX1
01X1
0011
0000
378 }
379 0 return [];
380 }
381  
382 2 ▶sub _normalize_page {
Subroutine _normalize_page: called CC=11 SCAR=33.7
383 2 my ( $self, $page ) = @_;
384 2 ▶ return { raw => $page } unless ref $page eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $page eq "HASH" 0 2 2
385 2 ▶ my $meta = $page->{metadata} || {};
Condition50%1/2
$page->{'metadata'} || {}
l!l
02
MC/DC0%0/1
$page->{'metadata'} || {}
$page->{'metadata'}
Truth table50%1/2
A
A= $page->{'metadata'}
Aresult
11
00
386 return {
387 success => $page->{success},
388 url => $meta->{sourceURL} // $page->{url} // $meta->{url},
389 final_url => $page->{redirected_url} // $page->{url} // $meta->{url},
390 status_code => $page->{status_code} // $page->{status} // $meta->{statusCode},
391 markdown => $self->_extract_markdown($page),
392 html => $page->{cleaned_html} // $page->{html},
393 raw_html => $page->{html},
394 title => $meta->{title},
395 links => $self->_extract_links($page),
396 metadata => $meta,
397 error => $page->{error_message} // $page->{error},
398 2 ▶ response_headers => $self->_lc_headers( $page->{response_headers} ),
Condition37%9/24
($meta->{"sourceURL"} // $page->{"url"}) // $meta->{"url"}
l!l&&r!l&&!r
200
$meta->{"sourceURL"} // $page->{"url"}
l!l&&r!l&&!r
020
($page->{"redirected_url"} // $page->{"url"}) // $meta->{"url"}
l!l&&r!l&&!r
200
$page->{"redirected_url"} // $page->{"url"}
l!l&&r!l&&!r
020
($page->{"status_code"} // $page->{"status"}) // $meta->{"statusCode"}
l!l&&r!l&&!r
200
$page->{"status_code"} // $page->{"status"}
l!l&&r!l&&!r
200
$page->{"cleaned_html"} // $page->{"html"}
l!l&&r!l&&!r
011
$page->{"error_message"} // $page->{"error"}
l!l&&r!l&&!r
002
MC/DC0%0/3
($meta->{"sourceURL"} // $page->{"url"}) // $meta->{"url"}
$meta->{"sourceURL"} $page->{"url"} $meta->{"url"}
MC/DC0%0/3
($page->{"redirected_url"} // $page->{"url"}) // $meta->{"url"}
$page->{"redirected_url"} $page->{"url"} $meta->{"url"}
MC/DC0%0/3
($page->{"status_code"} // $page->{"status"}) // $meta->{"statusCode"}
$page->{"status_code"} $page->{"status"} $meta->{"statusCode"}
MC/DC50%1/2
$page->{"cleaned_html"} // $page->{"html"}
$page->{"cleaned_html"} $page->{"html"}
MC/DC0%0/2
$page->{"error_message"} // $page->{"error"}
$page->{"error_message"} $page->{"error"}
Truth table25%1/4
A // B // C
A= $meta->{"sourceURL"}B= $page->{"url"}C= $meta->{"url"}
ABCresult
1XX1
01X1
0011
0000
Truth table25%1/4
A // B // C
A= $page->{"redirected_url"}B= $page->{"url"}C= $meta->{"url"}
ABCresult
1XX1
01X1
0011
0000
Truth table25%1/4
A // B // C
A= $page->{"status_code"}B= $page->{"status"}C= $meta->{"statusCode"}
ABCresult
1XX1
01X1
0011
0000
Truth table66%2/3
A // B
A= $page->{"cleaned_html"}B= $page->{"html"}
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $page->{"error_message"}B= $page->{"error"}
ABresult
1X1
011
000
399 raw => $page,
400 };
401 }
402  
403 # Lowercase all header keys for deterministic, case-insensitive matching by callers.
404 2 ▶sub _lc_headers {
Subroutine _lc_headers: called CC=2 SCAR=9.2
405 2 my ( $self, $h ) = @_;
406 2 ▶ return {} unless ref $h eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $h eq "HASH" 2 0 2
407 0 return { map { lc($_) => $h->{$_} } keys %$h };
408 }
409  
410 # Crawl4AI returns links as { internal => [...], external => [...] }, each entry
411 # a hash with href/text/title (older servers may send bare strings). Normalize
412 # to a stable { internal => [{href,text,title}], external => [...] } shape so the
413 # Result can expose them without callers reaching into raw.
414 2 ▶sub _extract_links {
Subroutine _extract_links: called CC=2 SCAR=7.6
415 2 my ( $self, $page ) = @_;
416 2 my $links = $page->{links};
417 2 ▶ return { internal => [], external => [] } unless ref $links eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $links eq "HASH" 2 0 2
418 return {
419 internal => $self->_normalize_link_list( $links->{internal} ),
420 0 external => $self->_normalize_link_list( $links->{external} ),
421 };
422 }
423  
424 0 ▶sub _normalize_link_list {
Subroutine _normalize_link_list: not called CC=2 SCAR=17.9
425 0 my ( $self, $list ) = @_;
426 0 ▶ return [] unless ref $list eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $list eq "ARRAY" 0 0 0
427 0 return [ map { $self->_normalize_link($_) } @$list ];
428 }
429  
430 0 ▶sub _normalize_link {
Subroutine _normalize_link: not called CC=4 SCAR=30.0
431 0 my ( $self, $link ) = @_;
432 0 ▶ return { href => $link } unless ref $link eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $link eq "HASH" 0 0 0
433 0 my $text = $link->{text};
434 0 ▶ $text = undef unless defined $text && length $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text and length $text 0 0 0
Condition0%0/3
defined $text and length $text
!ll&&!rl&&r
000
MC/DC0%0/2
defined $text and length $text
defined $text length $text
Truth table0%0/3
A and B
A= defined $textB= length $text
ABresult
0X0
100
111
435 return {
436 href => $link->{href},
437 text => $text,
438 title => $link->{title},
439 0 };
440 }
441  
442 # markdown is a plain string on old servers and a structured object on new ones.
443 # fit_markdown is preferred but is frequently an empty string (no content
444 # filter matched), so skip empty candidates instead of stopping at the first
445 # defined one.
446 2 ▶sub _extract_markdown {
Subroutine _extract_markdown: called CC=1 SCAR=0.0
447 2 my ( $self, $page ) = @_;
448 2 return resolve_markdown_chain( $page->{markdown} );
449 }
450  
451 #----------------------------------------------------------------------
452 # I/O + retry
453 #----------------------------------------------------------------------
454  
455 5 ▶sub do_request {
Subroutine do_request: called CC=16 SCAR=30.2
Pod documented
456 5 my ( $self, $req, $backend ) = @_;
457 5 ▶ croak "do_request needs an HTTP::Request" unless $self->is_request($req);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_request($req) 0 5 5
458 5 my $max = $self->max_attempts;
459 5 my $res;
460 11 ▶ my $is_transport = sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
461 11 my $r = shift;
462 11 ▶ return $r->code == 599 || ( ( $r->header('Client-Warning') // '' ) eq 'Internal response' );
Condition80%4/5
$r->code == 599 || ($r->header('Client-Warning') // '') eq 'Internal response'
l!l&&r!l&&!r
056
$r->header("Client-Warning") // ""
l!l
56
MC/DC50%1/2
$r->code == 599 || ($r->header('Client-Warning') // '') eq 'Internal response'
$r->code == 599 $r->header("Client-Warning")
Truth table66%2/3
A || B
A= $r->code == 599B= $r->header("Client-Warning")
ABresult
1X1
011
000
463 5 };
464 5 for my $attempt ( 1 .. $max ) {
465 6 $res = $self->ua->request($req);
466 6 ▶ last if $res->is_success;
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_success 0 6 6
467 6 my $code = $res->code;
468 6 my $transport = $is_transport->($res);
469 6 ▶ my $retryable = $transport || $self->_retry_status_set->{$code};
Condition66%2/3
$transport || $self->_retry_status_set->{$code}
l!l&&r!l&&!r
303
MC/DC50%1/2
$transport || $self->_retry_status_set->{$code}
$transport $self->_retry_status_set->{$code}
Truth table66%2/3
A || B
A= $transportB= $self->_retry_status_set->{$code}
ABresult
1X1
011
000
470 6 ▶ if ( $retryable && $attempt < $max ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retryable and $attempt < $max) 1 5 6
Condition100%3/3
$retryable and $attempt < $max
!ll&&!rl&&r
321
MC/DC100%2/2
$retryable and $attempt < $max
$retryable $attempt < $max
Truth table100%3/3
A and B
A= $retryableB= $attempt < $max
ABresult
0X0
100
111
471 1 ▶ my $delay = $self->retry_backoff->[ $attempt - 1 ] // $self->retry_backoff->[-1] // 1;
Condition40%2/5
($self->retry_backoff->[$attempt - 1] // $self->retry_backoff->[-1]) // 1
l!l
10
$self->retry_backoff->[$attempt - 1] // $self->retry_backoff->[-1]
l!l&&r!l&&!r
100
MC/DC0%0/2
($self->retry_backoff->[$attempt - 1] // $self->retry_backoff->[-1]) // 1
$self->retry_backoff->[$attempt - 1] $self->retry_backoff->[-1]
Truth table33%1/3
A // B
A= $self->retry_backoff->[$attempt - 1]B= $self->retry_backoff->[-1]
ABresult
1X1
011
000
472 1 ▶ if ( my $ra = $res->header('Retry-After') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ra = $res->header("Retry-After")) 0 1 1
473 0 ▶ $delay = $ra if $ra =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $ra =~ /^\d+$/ 0 0 0
474 }
475 1 ▶ $self->on_retry->( $attempt, $delay, $res ) if $self->on_retry;
Branch: 1 branch
BranchTrueFalseTotal
if $self->on_retry 0 1 1
476 1 $self->sleep_sub->($delay);
477 1 next;
478 }
479 5 last;
480 }
481 5 ▶ if ( !$res->is_success && $is_transport->($res) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $res->is_success and &$is_transport($res)) 2 3 5
Condition66%2/3
not $res->is_success and &$is_transport($res)
!ll&&!rl&&r
032
MC/DC50%1/2
not $res->is_success and &$is_transport($res)
not $res->is_success &$is_transport($res)
Truth table66%2/3
not(A) and B
A= not $res->is_successB= &$is_transport($res)
ABresult
0X0
100
111
482 2 ▶ die WWW::Crawl4AI::Error->new(
Condition40%2/5
($res->content // $res->message) // "unreachable"
l!l
20
$res->content // $res->message
l!l&&r!l&&!r
200
MC/DC0%0/2
($res->content // $res->message) // "unreachable"
$res->content $res->message
Truth table33%1/3
A // B
A= $res->contentB= $res->message
ABresult
1X1
011
000
483 type => 'transport',
484 message => "Crawl4AI transport error: " . ( $res->content // $res->message // 'unreachable' ),
485 response => $res,
486 status_code => 0,
487 backend => $backend,
488 );
489 }
490 3 return $res;
491 }
492  
493  
494 #----------------------------------------------------------------------
495 # Convenience (build + fire + parse)
496 #----------------------------------------------------------------------
497  
498 0 ▶sub crawl {
Subroutine crawl: not called CC=1 SCAR=6.9
Pod documented
499 0 my ( $self, $request, $backend ) = @_;
500 0 return $self->parse_crawl_response( $self->do_request( $self->crawl_request($request), $backend ), $backend );
501 }
502  
503  
504 0 ▶sub md {
Subroutine md: not called CC=2 SCAR=17.9
Pod documented
505 0 my ( $self, $url, %opts ) = @_;
506 0 ▶ my $request = $url->$_isa('WWW::Crawl4AI::Request')
Branch: 1 branch
BranchTrueFalseTotal
$url->$WWW::Crawl4AI::Client::_isa('WWW::Crawl4AI::Request') ? : 0 0 0
507 ? $url
508 : WWW::Crawl4AI::Request->new( urls => $url, %opts );
509 0 return $self->parse_md_response( $self->do_request( $self->md_request($request) ) );
510 }
511  
512 0 ▶sub job_submit {
Subroutine job_submit: not called CC=1 SCAR=6.9
Pod documented
513 0 my ( $self, $request ) = @_;
514 0 return $self->parse_job_submit_response( $self->do_request( $self->job_submit_request($request) ) );
515 }
516  
517 1 ▶sub job_status {
Subroutine job_status: called CC=1 SCAR=0.0
Pod documented
518 1 my ( $self, $task_id ) = @_;
519 1 return $self->parse_job_status_response( $self->do_request( $self->job_status_request($task_id) ) );
520 }
521  
522 2 ▶sub health {
Subroutine health: called CC=7 SCAR=22.3
Pod documented
523 2 my ( $self ) = @_;
524 2 my $healthy = eval {
525 2 my $res = $self->do_request( $self->health_request );
526 1 ▶ $self->parse_health_response($res) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->parse_health_response($res) ? : 0 0 0
527 };
528 2 ▶ if ( my $err = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $@) 2 0 2
529 2 ▶ my $message = ref $err && $err->$_isa('WWW::Crawl4AI::Error') ? $err->message : $err;
Branch: 1 branch
BranchTrueFalseTotal
ref $err && $err->$WWW::Crawl4AI::Client::_isa('WWW::Crawl4AI::Error') ? : 2 0 2
Condition33%1/3
ref $err and $err->$WWW::Crawl4AI::Client::_isa("WWW::Crawl4AI::Error")
!ll&&!rl&&r
002
MC/DC0%0/2
ref $err and $err->$WWW::Crawl4AI::Client::_isa("WWW::Crawl4AI::Error")
ref $err $err->$WWW::Crawl4AI::Client::_isa("WWW::Crawl4AI::Error")
Truth table33%1/3
A and B
A= ref $errB= $err->$WWW::Crawl4AI::Client::_isa("WWW::Crawl4AI::Error")
ABresult
0X0
100
111
530 2 ▶ $message = '' unless defined $message;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 0 2 2
531 # The reason is one line: LWP hangs a stack trace behind the connect error.
532 2 $message =~ s/\s*\n.*\z//s;
533 2 $message =~ s/\s+\z//;
534 2 ▶ warn 'crawl4ai health check failed: ' . $message . "\n" if length $message;
Branch: 1 branch
BranchTrueFalseTotal
if length $message 2 0 2
535 2 return 0;
536 }
537 0 return $healthy;
538 }
539  
540 0 ▶sub screenshot {
Subroutine screenshot: not called CC=1 SCAR=6.9
Pod documented
541 0 my ( $self, $url, %opts ) = @_;
542 0 return $self->parse_screenshot_response( $self->do_request( $self->screenshot_request( $url, %opts ) ) );
543 }
544  
545  
546 0 ▶sub pdf {
Subroutine pdf: not called CC=1 SCAR=6.9
Pod documented
547 0 my ( $self, $url, %opts ) = @_;
548 0 return $self->parse_pdf_response( $self->do_request( $self->pdf_request( $url, %opts ) ) );
549 }
550  
551 2 ▶sub html {
Subroutine html: called CC=1 SCAR=0.0
Pod documented
552 2 my ( $self, $url ) = @_;
553 2 return $self->parse_html_response( $self->do_request( $self->html_request($url) ) );
554 }
555  
556 0 ▶sub execute_js {
Subroutine execute_js: not called CC=1 SCAR=6.9
Pod documented
557 0 my ( $self, $url, $scripts ) = @_;
558 0 return $self->parse_execute_js_response( $self->do_request( $self->execute_js_request( $url, $scripts ) ) );
559 }
560  
561 0 ▶sub llm {
Subroutine llm: not called CC=1 SCAR=6.9
Pod documented
562 0 my ( $self, $url, $query, %opts ) = @_;
563 0 return $self->parse_llm_response( $self->do_request( $self->llm_request( $url, $query, %opts ) ) );
564 }
565  
566 0 ▶sub token {
Subroutine token: not called CC=1 SCAR=6.9
Pod documented
567 0 my ( $self, $email, %opts ) = @_;
568 0 return $self->parse_token_response( $self->do_request( $self->token_request( $email, %opts ) ) );
569 }
570  
571  
572 12 1;
573  
574 __END__
↑ Summary Crawl4AI/Detect.pm »