Page 1 of 1
PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:03 pm
by replyprabhat
HI All,
I am using php file_get_contents/CURL to access the google result. But, when I execute query
for e.g.
http://www.google.com/search?q=aviation ... ia&start=0 using CURL and again if I directly access the url through the browser and compare both the results from php curl and in the browser, they are different.
Does anybody know, what is happened? I have loss more than 2 days in it.
Re: PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:13 pm
by infolock
post your results please from both, and let's see what we can give you (don't have time to do it from scratch myself...)
Re: PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:17 pm
by replyprabhat
thankx for ur reply
this is my code
$html=file_get_contents("
http://www.google.com/search?q=aviation ... ia&start=0");
echo $html;
the result it display is different from the result that i search directly in google.com for "aviation security australia"
but, if i just copy the same url "
http://www.google.com/search?q=aviation ... ia&start=0" and paste it in the browser, the result is same for that i searched in google.
Re: PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:19 pm
by infolock
(please delete this post of mine, is a duplicate...)
Re: PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:21 pm
by replyprabhat
yeah thats true..i'm trying from both way..but the result is same whether i use curl or file_get_contents
Re: PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:22 pm
by infolock
thought you had a curl implimentation you were working with too?
Either way, it's because you aren't on their server. They use paths like /go/to/here/for/image for images. since you are'nt on google.com domain, you'll have to supply full path where it doesn't exist. so, the results will be the same, but images, css, etc that they don't supply full path to in their source code will need to be re-manufactured (or copy catted to your own server directory listing)
Re: PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:25 pm
by replyprabhat
but if i tried using google.com.au in curl, it gives me exact result. The only problem is with US server. Is there any way to access for US only. I tried finding the google.com IP and pass it but still doesn't work.
Re: PHP and Google Search Engine
Posted: Wed Nov 05, 2008 10:28 pm
by infolock
there are multiple google teams across the usa and world for that matter. not all of them (unfortunately) follow the same rules of the team, and ones with their own server get to write how they deem fit. including writing base paths instead of full paths =\.
in this case, all you can do is replace base paths with full paths. that or point it only to au page in your code. or, setup filestructure equal to that of the us server along with the files they need (or redirect pages or something) to make up for it when a base path is called. that's all you can do.
Re: PHP and Google Search Engine
Posted: Thu Nov 06, 2008 12:54 am
by j4IzbInao
I'm not sure if this is what you're talking about but it sure sounded like that the searchresults differed from when using php to fetch results to what you saw when you went to google via your webbrowser.
If that is what you're talking about it is because of the fact that google has multiple datacenters and you do not always get connected to the very same datacenter so two people, in the same office, can get different search-results even though they're using the exact same search-terms & google-website.