I would like to know if it's possible to check if URL is indexed by Google using PHP.
Is this against their ToS?
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With