Crawl4AI/Strategy.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 93.3% 28 / 30 CC 3 SCAR 6.3
CC
3
Cov
95%
_request
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Crawl4AI/Strategy/CloakBrowser.pm ↑ Summary Crawl4AI/Strategy/Proxy.pm »
1 package WWW::Crawl4AI::Strategy;
2 # ABSTRACT: role for a single crawl strategy in the WWW::Crawl4AI fallback chain
3 6 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use WWW::Crawl4AI::Request ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 our $VERSION = '0.001';
7  
8  
9 6 requires 'name';
10 6 requires 'cost_class';
11  
12 # Whether this strategy belongs in the chain for the given crawler.
13 # Plain/Browser/Stealth are always applicable; CloakBrowser/Proxy/Callback
14 # override this to gate on configuration.
15 26 ▶sub applicable { 1 }
Subroutine applicable: called CC=1 SCAR=0.0
Pod documented
16  
17  
18  
19  
20 # Default execution: build a Request and run it through the client, returning a
21 # single normalized page. Strategies that don't fetch via Crawl4AI (Callback)
22 # override this instead of providing build_request.
23 39 ▶sub crawl {
Subroutine crawl: called CC=1 SCAR=0.0
Pod documented
24 39 my ( $self, $crawler, $url, %opts ) = @_;
25 39 my $req = $self->build_request( $crawler, $url, %opts );
26 39 my $pages = $crawler->client->crawl( $req, $self->name );
27 37 return $pages->[0];
28 }
29  
30  
31  
32 # Helper for build_request implementations.
33 39 ▶sub _request {
Subroutine _request: called CC=3 SCAR=11.1
34 39 my ( $self, $url, %p ) = @_;
35 return WWW::Crawl4AI::Request->new(
36 urls => $url,
37 browser_params => $p{browser} || {},
38 crawler_params => $p{crawler} || {},
39 39 ▶ );
Condition75%3/4
$p{'browser'} || {}
l!l
390
$p{'crawler'} || {}
l!l
1227
MC/DC0%0/1
$p{'browser'} || {}
$p{'browser'}
MC/DC100%1/1
$p{'crawler'} || {}
$p{'crawler'}
Truth table50%1/2
A
A= $p{'browser'}
Aresult
11
00
Truth table100%2/2
A
A= $p{'crawler'}
Aresult
11
00
40 }
41  
42  
43 6 1;
44  
45 __END__
« Crawl4AI/Strategy/CloakBrowser.pm ↑ Summary Crawl4AI/Strategy/Proxy.pm »