Page 1 of 1

Issue with querry to Google

Posted: Mon Sep 29, 2008 3:05 pm
by someguyhere
http://www.wildfiremarketinggroup.com/A ... ndexed.php

The following code does not seem to return the corect data. Is there somethign obvious that I'm mising? Am I passing the querry to Google properly?

Code: Select all

<?php
$return=file_get_contents("http://www.google.com/search?hl=en&rlz=1T4ADBF_enUS262US262&q=site%3Ahttp%3A%2F%2Fwww.msn.com");
preg_match("/of about (.*?) from/",$return,$output); $output=$output[1];
echo'Pages indexed: '.$output;
?>
Also, once I get this working, I plan to have it display the pages indexed for multiple sites. I was planning to load them into an array from a flat file - is that the right approach? (the array part I have already sorted out thanks to the people here on this forum).

Thanks in advance!

Re: Issue with querry to Google

Posted: Mon Sep 29, 2008 3:07 pm
by someguyhere
Disregard the number of pages...it seems to be showing the correct number now. I would still like to know if I am passing the querry to Google the most effective/efficient way though.

Re: Issue with querry to Google

Posted: Tue Sep 30, 2008 3:13 pm
by someguyhere
someguyhere wrote:http://www.wildfiremarketinggroup.com/A ... ndexed.php

Am I passing the querry to Google properly?

Code: Select all

<?php
$return=file_get_contents("http://www.google.com/search?hl=en&rlz=1T4ADBF_enUS262US262&q=site%3Ahttp%3A%2F%2Fwww.msn.com");
preg_match("/of about (.*?) from/",$return,$output); $output=$output[1];
echo'Pages indexed: '.$output;
?>
Also, once I get this working, I plan to have it display the pages indexed for multiple sites. I was planning to load them into an array from a flat file - is that the right approach? (the array part I have already sorted out thanks to the people here on this forum).

Thanks in advance!

Re: Issue with querry to Google

Posted: Tue Sep 30, 2008 3:55 pm
by onion2k
I really hate it when people bump their topics. Anyway...

No, you aren't doing this in the most efficient way you could be. Your PHP script will stop until the page from Google has been loaded. That's not really a problem if you're only checking a single site but if you're checking lots of sites the script is going to be really, really slow. Curl, or curl multi, is a better approach (in my opinion).

Your script also suffers from a reliance on Google's page format. If they change the wording, or even just the layout, your script will break.