1 month ago

Get google search first result with Goutte

Posted 1 month ago by Gabotronix

Hi everybody, I want to get the first result url of google search using Goutte PHP library, sadly I haven't found many info on how to get a list of results from google using Goutte...

I'm using laravel and I already installed Guzzle and Goutte libraries with composer.

public function getGoogleResults(Request $request)
        // Extract and sanatize input:
        $domain = $request->input('domain');
        $terms = $request->input('terms');
        // Build up a search URL:
        $pages = 10;
        $url = ''.http_build_query(array('q' => $terms));
            // Request search results:
        $client = new Goutte\Client;
        $crawler = $client->request('GET', $url);

Please sign in or create an account to participate in this conversation.