NAME
WWW::Crawl4AI::Strategy - role for a single crawl strategy in the WWW::Crawl4AI fallback chain
VERSION
version 0.001
SYNOPSIS
package WWW::Crawl4AI::Strategy::Mine;
use Moo;
with 'WWW::Crawl4AI::Strategy';
sub name { 'crawl4ai_mine' }
sub cost_class { 'browser' }
sub build_request {
my ( $self, $crawler, $url, %opts ) = @_;
return $self->_request( $url, browser => { headless => 1 } );
}
DESCRIPTION
A Moo::Role implemented by every strategy in the chain. Each strategy maps a URL onto a Crawl4AI request with a particular browser/crawler configuration, and declares its cost tier. The chain in WWW::Crawl4AI runs applicable strategies in cost order until one returns a page that WWW::Crawl4AI::Detect rates good.
name
Required. The backend identifier, e.g. crawl4ai_plain.
cost_class
Required. One of cheap, browser, stealth, paid.
applicable
Returns true if the strategy should be in the chain for $crawler. Default true; gated strategies override it.
crawl
Runs the strategy and returns a single normalized page hashref (or throws a WWW::Crawl4AI::Error). The default implementation calls "build_request" and the crawler's client.
build_request
Consumers implement this (unless they override "crawl"): given ($crawler, $url, %opts), return a WWW::Crawl4AI::Request.
_request
Convenience for "build_request": $self->_request($url, browser => {...}, crawler => {...}) builds a WWW::Crawl4AI::Request.
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-crawl4ai/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de> https://raudss.us/
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.