Google Custom Search API, for country-only results

I am making some PHP code that accepts a specific search phrase, url, and does a search on google search results until it finds a URL (only the first 100 results). My problem is that this only works for the USA. I tried adding the & cr = parameter, but it still returns US results.

The full URL that I use for the request is:

https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=CX_VALUE&q=KEYWORD&cr=COUNTRY&alt=JSON

Does anyone have any experience? I want to see results in the UK. Tried insert and cr = countryUK, but still only results in the USA.

Thanks:)

Regards, Stian

+4
source share
1 answer

Use the gl=<country code> parameter to restrict it to the country of your choice (so gl = gb for uk).

More details here:

http://googleajaxsearchapi.blogspot.com/2009/10/web-search-in-your-country.html

+3
source

Source: https://habr.com/ru/post/1336548/


All Articles