how to spoof location so google autocomplete API will provide local results, ideally with R

935 views Asked by At

google has an API for downloading search suggestions:

https://www.google.com/support/enterprise/static/gsa/docs/admin/70/gsa_doc_set/xml_reference/query_suggestion.html

unfortunately, as far as i can tell, these results are specific to your location. for an analysis, i would like to be able to define the city/location that google thinks it is making the suggestion to. here's what happens when i scrape from dar es salaam, tanzania:

http://suggestqueries.google.com/complete/search?client=firefox&q=insurance

["insurance",["insurance","insurance companies in tanzania","insurance group of tanzania","insurance principles","insurance act","insurance policy","insurance act tanzania","insurance act 2009","insurance definition","insurance industry in tanzania"]]

i understand that a vpn would partially solve this issue, but only by giving me a different location and not lots of locations. is there a reasonable way to replicate this sort of thing quickly and easily from, say, the 100 largest cities in the united states?

confirmation that results differ within the usa- enter image description here

thanks!

2

There are 2 answers

0
thebenedict On

The hl param for interface language changes the search results, but I can't tell if it's actually changing the location. For example:

http://suggestqueries.google.com/complete/search?client=chrome&q=why&hl=FR

Here's an example with 5 different values of hl:

http://jsbin.com/tusacufaza/edit?js,output

3
Ali Al Amine On

Google will use your IP and your location history (if turned on) to determine your location.

To be able to go around it, you can spoof your IP while logged off your google account (but I don't know if google will consider it a trial of hacking no matter what your intentions are).

Another way is to use Tor browser (even though it is not it's original purpose). You can configure tor to exit from a certain country using the Exitnode parameter in the torrc config file

As found in the docs:

ExitNodes node,node,…

A list of identity fingerprints, country codes, and address patterns of nodes to use as exit node

But if you want a fast way to do it, I don't think that's possible since google wants to know the real location of the users and have put a lot of effort into making such tricks fail.