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

3

8

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!

Elias answered 14/6, 2015 at 15:23 Comment(5)
What makes you think the query suggestion service is location-specific beyond the top-/country-level Google search? I can't find any documentation on the query suggestion service that would indicate something location-specific is going on there. at least nothing as sophisticated as the location-specific search result ranking?Entente
@ForrestR.Stevens great question, but i'm pretty sure location matters - at least two computers across the country in chrome private browse gave me different results. always possible i'm screwing up something elseElias
Just to confirm, you're talking about the query suggestions and not search results? I can't get query suggestions to give me different results based on the same prompt at least within country...Entente
@ForrestR.Stevens yes, query suggestions. my example image gives different suggestions within the same country..Elias
Interesting, I definitely stand corrected. I'm afraid your best bet would be to contact Google and see if there are any hidden hooks in the API to hard code the location information. But I suspect given how search results are location driven by reverse-IP, in addition to a variety of other triangulation, if query suggestions work similarly a VPN connection would be about the only way.Entente
M
1

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.

Medawar answered 14/6, 2015 at 19:23 Comment(3)
thanks! i am looking for a way to do this programmatically, so to use tor it would have to be torified -- trac.torproject.org/projects/tor/wiki/doc/TorifyHOWTO -- not sure how easy that is to incorporate into an R web scrape..Elias
@AnthonyDamico Actually the link you are following is to torrify an app that you didn't write. To go through tor in your own application, you can check out stem.torproject.org/faq.html#how-do-i-connect-to-tor and svn.torproject.org/svn/torctl/trunk/doc/howto.txt. As for changing the exit node programatically, you can search for the ExitNodes in the torrc, edit that line and tell tor to reload that.Medawar
To achieve the results you are looking for, you should find a way to change your IP, and the only ways I know of are anonimity software, vpn's and some other IP spoofing techniques which require some hacking to be done and I would not recommend doing the last option unless you are looking for trouble.Medawar
L
1

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

Librarianship answered 15/6, 2015 at 9:46 Comment(0)
S
0

Can use gl=country_location, "in" in my case. Worked for me in India. Example: "http://suggestqueries.google.com/complete/search?client=chrome&gl=in&q="

Snailpaced answered 27/7 at 7:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.