Custom JSON API search using operator "site"

61 Views Asked by At

I need to check several hundred websites/pages a day for the presence of a Google index, in fact, I need an imitation of site:something.com. I use Custom Search JSON API `

$search_query = http_build_query(
      array(
          "key" => $api_key, 
          "cx" => $search_id,
          "q" => "site:".$link,
          "num" => "10",
          "safe" => "off"
      )
  );

  $json = file_get_contents("https://www.googleapis.com/customsearch/v1?" . $search_query);
  $data = json_decode($json, true);

`

and often in the response it shows that there are no results, although the site is in the index. Checked "handles" through Google itself.

What could be the problem/error?

if you send the query "q" => "site:mysite.com" through the script, then there are no results in the response (variable and items in the response), but if site:mysite.com is entered in the search string, then the site is found.

tested through https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list?apix=true&apix_params=%7B%22cx%22%3A%22df93080fceb189de3%22%2C%22q%22%3A%22site%3Ahttps%3A%2F%2Fonodo.org%2Fvisualizations%2F208836%22%2C%22safe%22%3A%22off%22%7D

expected 1 result but API returned 0 results

0

There are 0 best solutions below