Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if URL is indexed by Google using PHP

Tags:

php

indexing

I would like to know if it's possible to check if URL is indexed by Google using PHP.

Is this against their ToS?

like image 574
Gabriel Bianconi Avatar asked Oct 13 '22 19:10

Gabriel Bianconi


2 Answers

You can read here (relevant citation below) for an answer to the ToS part of this. Basically, without an API key and their permission, it probably is not a good idea. However, due to the volume they handle, you might be able to get away with it if you're not making TONS of requests.

PageRank checking is something else that people often try to do, but they don't place as much weight on this merit (rumor has it), and the older style API keys are really hard to find.

Don't use unauthorized computer programs to submit pages, check rankings, etc. Such programs consume computing resources and violate our Terms of Service. Google does not recommend the use of products such as WebPosition Gold™ that send automatic or programmatic queries to Google.

like image 125
zanlok Avatar answered Oct 18 '22 03:10

zanlok


To do so without an API is against the TOS. For low volume, you can:

// CHECK IF PAGE IS IN GOOGLE INDEX
$domain = 'stackexchange.com';
if (strstr(file_get_contents("http://www.google.com/search?q=site:$domain"), 'did not match any documents')) {
  // Page is not in the index
  print 'No Go!';
}
else {
  print 'All Good!';
}
exit;
like image 22
Kogs Avatar answered Oct 18 '22 02:10

Kogs