<?php
$query = http_build_query(["engine" => "google", "q" => "coffee shops"]);
$ch = curl_init("https://api.scraperdata.com/v1/search?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-Key: YOUR_API_KEY"],
CURLOPT_TIMEOUT => 60,
]);
$data = json_decode(curl_exec($ch), true);
print_r($data);
{ "search_metadata": { "status": "Success", "pages": 1, "credits_charged": 1 }, "search_parameters": { "engine": "google", "q": "coffee shops", "gl": "us" }, "organic_results": [ { "position": 1, "title": "The 12 Best Coffee Shops Near You", "link": "https://www.example.com/coffee", "snippet": "Hours, reviews and photos for the best cafes..." } ]}