Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Check if URL is indexed by Google
function indexed($url) {
$url = '' . 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';

This comment has been minimized.

Copy link

@gaptekupdate gaptekupdate commented Apr 8, 2017

love this.. thx


This comment has been minimized.

Copy link

@dryleaf dryleaf commented Aug 22, 2019

curl -I --user-agent 'Chrome 10'<your url here>


This comment has been minimized.

Copy link

@yuis-ice yuis-ice commented Oct 1, 2020


	local url="${1}"
	local code
	code="$( curl --user-agent 'Chrome 10' -s -o /dev/null -w "%{http_code}" ''"${url}" )"

	[[ "${code}" == "200" ]] && return 0 || return 1

check_if_url_google_index "" && echo "yes" || echo "no"
check_if_url_google_index "" && echo "yes" || echo "no"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.