Phil Barber
Phil Barber

Reputation: 11

How to fake a location for a Google search?

So I am trying to write a script that querys a website from multiple different locations and devices and records the results, I am using google as the benchmark for this.

From what I have read it seems Google uses nearby WiFi networks to pinpoint your location. I am not on wireless however so it seems it just guesses based on your ip. If this is the case, will it be possible to do this without using a proxy of some kind?

Now what I have so far is written in php and uses curl to set the relevant options. I am using curl in order to change the user agent to fake different devices. Is it possible to use curl to change the location data also?

If curl is not the best way to do this then I am open to change to a different method, but any alternative would need a way to set the user agent as well as location.

I have seen from this post that you can override what your current position in Chrome is via the Geolocation API. I am concerned however that this will only change the location locally (ie after you have a response), so would defeat the purpose. Also, I am not sure where this code needs to be written. Would it be in the javascript in the browser itself? So not useful for an external script?

Any thoughts appreciated!

Upvotes: 0

Views: 1444

Answers (3)

Fernando Bettoni
Fernando Bettoni

Reputation: 11

You can use the device emulation

here

Upvotes: 1

Elentriel
Elentriel

Reputation: 1237

You can try something along these lines

curl_setopt( $curl, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip_to_show", "HTTP_X_FORWARDED_FOR: $ip_to_show"));

Which might or might not work depending on who you try to fool (you are not changing your actual ip but your http request headers, if they listen to that you are set)

Upvotes: 0

iXCray
iXCray

Reputation: 1092

You are able to specify location in settings for search query.

Or use NCR links with curl, like http://www.google.com/ncr

This works for other countries too, so for example I was able to go to Deutschland Google with:

http://www.google.de/ncr

Upvotes: 0

Related Questions