Google Custom Search API, Howto return country specific results only - google-search-api

I am making some PHP code which takes a given search phrase and url and searches through the google search results until it finds the url (only first 100 results). My problem is, this is only working for the US. I have tried adding the "&cr=" option, but it still on returns US results.
The full URL I am using 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 with this? I want to be able to see UK results. Tried inserting &cr=countryUK , but still only does US results.
Thanks :)
Regards,
Stian

Use the gl=<country code> param to limit it to your country of choice (so gl=gb for the uk).
More info here:
http://googleajaxsearchapi.blogspot.com/2009/10/web-search-in-your-country.html

Related

The first result in Google is not my homepage

When you type hackisition on Google, it returns the following url as first result:
https://www.hackisition.com/en/
// instead of
https://www.hackisition.com/
I'd like to replace that link by the real homepage. How can I do that? Is there a way to specifically ask Google to show this homepage?
I am getting "https://www.hackisition.com/" as first result for "hackisition". I'm not sure why you're getting such result. Try to clear cookies and turn off VPN/Proxy if you're using one.
We are getting result as you said , so I suggest to clear cache
Maybe that is because of User location.
That mean countries preferred English on search would be able to see /en
and other countries that not prefer English will see the non /en result.
Search your website on
Google.ae
Google.DK
you'll see https://www.hackisition.com in result not https://www.hackisition.com/en.
But if you search in Google.com, Google.eu you'll see the result https://www.hackisition.com/en
Hope this would be the solution of your problem.

How to get result of google place API In Hindi/Korean?

I need to get Api Response in Hindi and Korean. I have passed languge parameter with(hi for hindi) and checking its response by simulator but it's result is always in English.
Here is Url that was made by me for getting Search places result in Hindi
https://maps.googleapis.com/maps/api/place/search/json?location=28.580000,77.330000&sensor=true&key=AIzaSyAnAS2zrUGCxU5zp_JvuCrBWLwndv7rElI&name=BURGER&rankby=distance&language=hi
Please tell me if anybody has idea bout my question.
See the description of the language-parameter:
The language code, indicating in which language the results should be returned, if possible
There is no guarantee that the results will be in the desired language.
When there is no translation for the desired language/particular place-detail available, you will not get it.
So your attempt is correct, but you may not get better results.
When you inspect the response you'll see that you get results in hindi(where available) e.g. for Sangam Fry Burger -> संगम फ्राय बर्गर

Google Custom search bug?

I have implemented google custom search (https://developers.google.com/custom-search/json-api/v1/reference/cse/list#request) that searches flickr and other sources on my site and now suddenly it gives me very wierd results.
My query looks like this (key and search engine id removed)
https://www.googleapis.com/customsearch/v1?num=10&rights=cc_attribute&searchType=image&safe=high&key={key}&cx={searchengine}&q=cat&start=1
So a search on 'cat' obviously gives totalResult:219000 in the response. I get 10 result per request but when I use start=11
https://www.googleapis.com/customsearch/v1?num=10&rights=cc_attribute&searchType=image&safe=high&key={key}&cx={searchengine}&q=cat&start=11
I get totalResults:12!
What am I doing wrong? This used to work.

sharepoint crawl rule to exclude AllItems.aspx , but get an item/document in search resu lts if queried in the search box

I followed this blog Tips 1and created a crawl rule http://.*forms/allitems.aspx and ran full crawl. I no longer get the results with AllItems.aspx. However, if there is any document with name Something.doc in a Document Library , it no longer gets pulled in the search results.
I think what I desire is a basic functionality, like the user should not get to see Allitems.aspx in the search results but should get the item/document with names entered in the search box.
Please let me know if I am missing anything. I have already put in 24 hours...googled the max I could.
It seems that an Index Reset is required. Here's the steps I did:
1. Add the following crawl rule to exclude: *://*allitems.aspx.
2. Index Reset.
3. Full Crawl.
I could not find a good way to do this using crawl rules. Instead, I opted to set up a restriction on the search results web part.
In the search results web part properties, select "Change Query"
Add a property filter to exclude anything with "AllItems" (and any other exclusions you want in place.
Used Steve Mann's blog as a reference and for the images: http://stevemannspath.blogspot.com/2013/04/sharepoint-2013-search-removing-junk.html

google analytics API, how to extract pageviews for a specific page?

Google Analytics API: how to extract pageviews for a specific page?
I tried using something like
ga:pagePath=~page.php%3fid%3d44 (page.php?id=44)
but it doesn't seem to work... I get "no results found" where I have 20 pageviews for sure
UPDATE
I think I found the solution
ga:pagePath==/website/page.php?id=44
for some reason I had to include the complete path and ==
To use a partial path to match for a page in filters you should use
ga:pagePath=#page.php?id=44
=# tells ga to match a substring.
What you were originally using was incorrect for this.
I think your problem is that you put the hex version of the ? and = characters into your query, which doesn't match how Analytics stores the page paths. If you change these to the normal characters it should work:
ga:pagePath=~page.php?id=44
Your other solution should work as well but is a bit more inflexible in case you wanted to tweak the query to return other pages.