Hey Guys,
Does anybody out there have any code / ideas / examples of php code that will check if a website is indexed in google?
Code To Check if site is indexed in Google
Moderator: General Moderators
-
shanehunter
- Forum Commoner
- Posts: 30
- Joined: Sun Jun 27, 2010 3:43 pm
Re: Code To Check if site is indexed in Google
You might be able to find something here: http://www.google.com/webmasters/
Also I know there's a way you can upload your site map to google for indexing... just not sure I remember where I did it.
Also I know there's a way you can upload your site map to google for indexing... just not sure I remember where I did it.
-
shanehunter
- Forum Commoner
- Posts: 30
- Joined: Sun Jun 27, 2010 3:43 pm
Re: Code To Check if site is indexed in Google
Hi Jade,
Thanks for the quick return, but not exactly what I had in mind. =)
I need a php script that checks to see if a URL that is located in a text file is indexed in google (in google, you can just search "info:urlhere.com") then, if it is indexed, to move that url from the original text file into a new one. if it's not indexed, then it would move the url into an alternate text file.
make sense?
Thanks for the quick return, but not exactly what I had in mind. =)
I need a php script that checks to see if a URL that is located in a text file is indexed in google (in google, you can just search "info:urlhere.com") then, if it is indexed, to move that url from the original text file into a new one. if it's not indexed, then it would move the url into an alternate text file.
make sense?
Re: Code To Check if site is indexed in Google
Ooh so you don't want to see which pages of the website are indexed, you just want to know if google has the site or not.
You'll need to be able to have allow_url_fopen turned on in your php.ini file. Then you need to do something like this:
You'll need to be able to have allow_url_fopen turned on in your php.ini file. Then you need to do something like this:
Code: Select all
<?php
$url_list = array("whiteoakstables.net", "simdog.net", "bskgame.com", "horsega.me");
$found_index = array();
$missing_index = array();
foreach ($url_list => $item as $url)
{
$googlesearch = "http://www.google.com/#hl=en&q=info%3A$url";
$handle = fopen($googlesearch, "rb");
$contents = stream_get_contents($handle);
if (strpos($contents, "<cite>" . $url . "</cite>")) //or however you want to determine google has indexed this url
array_push($found_index, $url);
else
array_push($missing_index, $url);
}
echo "Missing URLs:";
print_r($missing_index);
?>