crwlrsoft / crawler

Library for Rapid (Web) Crawler and Scraper Development
https://www.crwlr.software/packages/crawler
MIT License
325 stars 11 forks source link

"Microseconds" not found #110

Closed flanderboy closed 1 year ago

flanderboy commented 1 year ago

Hello @otsch, I receve this error

PHP Fatal error: Uncaught Error: Class "Microseconds" not found in .../crawler.php:65

for this code reader on documentations

        public function loader(UserAgentInterface $userAgent, LoggerInterface $logger): LoaderInterface {

            $cache = new FileCache(__DIR__ . '/cachedir');
            $cache->ttl(new DateInterval('P2D'));
            $cache->useCompression();

            $loader = new HttpLoader($userAgent, logger: $logger);

            $loader->throttle()
                ->waitBetween(
                    Microseconds::fromSeconds(1.0),
                    Microseconds::fromSeconds(2.0)
                );

            $loader->setCache($cache);  

            return $loader;

        }
otsch commented 1 year ago

Ah, sorry, the import statement for the Microseconds class is missing in the code example in the docs. I'll add it. Just add this in your code:

use Crwlr\Crawler\Loader\Http\Politeness\TimingUnits\Microseconds;