Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i override Google SERP with automatic IP location determination programmatically?

I mean, i can specify preferred SERP location search options on google serp page, for sure. I guess there is way to make it hapenns with curl.

Here is some history. I've used SEOStats onto my project. It's good. The I've got interesting article about local searches with undocumented google search parameter UULE, and used it for getting local results. And it works fine for some time. Then I've to implement getting results with proxies. And that's it. Something is going wrong today as suggested in this comment at the same article. This year is full of surprises. Results now ignoring parameter UULE for some reason sometimes using proxy. It returns me proxy located local results. But it's partially fine without proxy.

So, I have to guess.

Should make an additional request every time with same (I have back engineered this, look at code below) user processes setting current location OR may be i have missed some request headers OR is there simpliest way and I am kinda stupid?

// Setting location like a boss
$randomKey = mt_rand(1111,999999);          

// SEOStats Curl wrapper
$test = static::gCurl("?q=testing" . $randomKey . "#q=testing". $randomKey, false, Config\DefaultSettings::ALLOW_GOOGLE_COOKIES, $proxy );

$q = explode(";;--;;", $test);
preg_match("/;sig=(.*?)\"/i", $test, $out);
$key = $out[1];

//Suggested Google Geocoder location
$zc = (!empty($location)) ? urlencode($location) : urlencode("Home sweet home");
$url = "https://www.google." . Config\DefaultSettings::GOOGLE_TLD . "/" . "uul?muul=4_18&luul=$zc&uulo=1&usg=$key&hl=ru";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

// There should be magic not tested yet
like image 426
Andrew Rumm Avatar asked May 18 '15 14:05

Andrew Rumm


1 Answers

Yes you can, you should use the local domain (which you already use) and the cr GET parameter to set the default country along with a matching hl parameter to set the default language.

Then you get URL's like:

https://www.google.nl/search?cr=countryNL&hl=nl&num=50&q={your keyword}
like image 87
redelschaap Avatar answered Sep 18 '22 07:09

redelschaap