1. Go to this page and download the library: Download edulazaro/larascraper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
edulazaro / larascraper example snippets
namespace App\Scrapers;
use EduLazaro\Larascraper\Scraper;
class BikeScraper extends Scraper
{
protected function handle(): array
{
return [
'title' => $this->crawler->filter('title')->text('')
];
}
}
use App\Scrapers\BikeScraper;
$data = BikeScraper::scrape('https://whatever.com/bikes/4')
->proxy('ip:port', 'username', 'password') // Optional
->timeout(10000) // Optional timeout in ms
->headers(['Accept-Language' => 'en']) // Optional headers
->run();
dd($data);
namespace App\Scrapers;
use EduLazaro\Larascraper\Scraper;
class BikeScraper extends Scraper
{
protected function handle(string $name): array
{
return [
'title' => $this->crawler->filter($name)->text('')
];
}
}
use App\Scrapers\BikeScraper;
BikeScraper::scrape('https://whatever.com/bikes/4')->run(name: 'title');