Skip to content

Instantly share code, notes, and snippets.

@tojibon
Forked from qsun/indexed.php
Created June 24, 2016 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tojibon/abcb543e4eb76425d081cd3ce335bb14 to your computer and use it in GitHub Desktop.
Save tojibon/abcb543e4eb76425d081cd3ce335bb14 to your computer and use it in GitHub Desktop.
Check if URL is indexed by Google
<?php
function indexed($url) {
$url = 'http://webcache.googleusercontent.com/search?q=cache:' . urlencode($url);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Chrome 10');
if (!curl_exec($ch)) {
// var_dump('failed');
return false;
}
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// var_dump($code);
return $code == '200';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment