0

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

2
  • Some parts of your question are still in russian ;-) But to your question. It looks like that the google api protected for multiple request one after the other. Try to insert a sleep(1); between the requests. Commented Jan 10, 2023 at 21:46
  • 1
    @MaikLowrey I tried use only 1 url, not list Commented Jan 10, 2023 at 21:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.