Goutte @ Laravel

composer require fabpot/goutte
use Goutte\Client;

class WebScraperController extends Controller
{
    public function scrape()
    {
        $url = 'https://www.example.com';
        $client = new Client();
        $crawler = $client->request('GET', $url);

        // 找到所有標題元素
        $crawler->filter('h2')->each(function ($node) {
            dump($node->text());
        });

        // 找到所有鏈接元素
        $crawler->filter('a')->each(function ($node) {
            dump($node->text(), $node->attr('href'));
        });
    }
}