Spatie\Crawler\CrawlObserver::willCrawl PHP Method

willCrawl() public method

Called when the crawler will crawl the url.
public willCrawl ( Url $url ) : void
$url Url
return void
    public function willCrawl(Url $url);

Usage Example

Example #1
0
 protected function getCrawlRequests() : Generator
 {
     $i = 0;
     while ($crawlUrl = $this->crawlQueue->getPendingUrlAtIndex($i)) {
         if (!$this->crawlProfile->shouldCrawl($crawlUrl->url)) {
             $i++;
             continue;
         }
         if ($this->crawlQueue->hasAlreadyBeenProcessed($crawlUrl)) {
             $i++;
             continue;
         }
         $this->crawlObserver->willCrawl($crawlUrl->url);
         $this->crawlQueue->markAsProcessed($crawlUrl);
         (yield new Request('GET', (string) $crawlUrl->url));
         $i++;
     }
 }
All Usage Examples Of Spatie\Crawler\CrawlObserver::willCrawl