You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey,
Is there any sample example how to get strart with this?
My code:
`use Spatie\Crawler\Crawler;
use Spatie\Crawler\CrawlObservers\CrawlObserver;
use Psr\Http\Message\UriInterface;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\RequestException;
require DIR . '/vendor/autoload.php';
class MyCrawl extends CrawlObserver {
private $res;
public function willCrawl($url) {
var_dump('willCrawl'.$url);
}
public function finishedCrawling() {
var_dump('finishedCrawling');
}
public function crawlFailed( UriInterface $url,RequestException $requestException,?UriInterface $foundOnUrl = null): void {
var_dump('crawlFailed');
}
public function crawled(UriInterface $url,ResponseInterface $response,?UriInterface $foundOnUrl = null): void {
$html = $response->getBody()->getContents();
var_dump($html);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey,
Is there any sample example how to get strart with this?
My code:
`use Spatie\Crawler\Crawler;
use Spatie\Crawler\CrawlObservers\CrawlObserver;
use Psr\Http\Message\UriInterface;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\RequestException;
require DIR . '/vendor/autoload.php';
class MyCrawl extends CrawlObserver {
private $res;
}
$observ = new MyCrawl();
$url = 'https://www.facebook.com/Mhfootballclub/about/';
Crawler::create()->setCrawlObserver($observ)->startCrawling($url);`
What am i missing?
Beta Was this translation helpful? Give feedback.
All reactions