Filter Google Custom Search Engine results by site - google-custom-search

I have been having issues using the Custom Search Engine API while (trying to) using the functionality of its specific site search.
I have created (using the web console) a CSE and defined it to search in 2 sites:
*.ebay.com
*.amazon.com
First, when searching for the term 'pcrush' (with curl), I receive results from amazon.com and ebay.com domains, as expected. this is ok.
curl -X GET 'https://www.googleapis.com/customsearch/v1?key=<my-key>&cx=<my-cx>&q=pcrush'
When I try making the same search but limit the results to be just from a specific site, I still get results from both eay and amazon.
Here, I want to receive only the ebay.com results:
adding &as_sitesearch=ebay.com
adding &as_sitesearch=ebay.com&as_dt=i
adding &as_sitesearch=amazon.com&as_dt=e
all of the above example, when the domain is *.ebay.com or *.amazon.com
It all still returned results both from ebay.com and amazon.com
I should mention we are following the API as described here.
What am I doing wrong?
Thanks in advance.

Related

Different results locally and in staging

I'm using google custom search engine with a search engine that searches specific sites and excludes some patterns in these sites.
I'm testing the api locally and I receive 12 results. I test the same exact call in staging (heroku us region) and I receive 410 results.
Does google personalise the results when using a custom search engine?
If yes, how do I turn it off? If no, do you have any idea why am I seeing this difference?
Update
Ok I did a test. I issued the exact same request by using a proxy and not, and the results are different (vastly).
Now, the question is, can this behaviour be disabled?
Ok found it. By specifying the userIp param https://developers.google.com/custom-search/json-api/v1/using_rest it will force google to use the same behaviour regardless of location.

How to remove URLs with argument in google result

I have a website which I have recently started and also submitted my sitemap on google webmaster tool. My site got index whiten short time but whenever I search about my website on google, I see two three version of my same pages with diff URL arguments on each
Means suppose my site name is example.com, so when I search about exmaple.com on Google I get the results like following
www.example.com/?page=2
www.example.com/something/?page=3
www.example.com
As I know result 1 and result 3 are same, why are they being shown separately ? I don't have any such URL in my sitemap and not even in any of my html page so why is this happening I am little confused. I want to get rid of it
Also result no 2 should be displayed simple as www.exaple.com/something
and not like www.example.com/something?page=3
There is actually a setting in google webmaster tool which helps in removing URLs with parameters. To access & configure the setting, navigate to Webmaster tool --> Crawl --> URL Parameters and set them according to your needs
I also found following article useful for understanding concept behind those parameters and how could we remove pages getting crawled with unnecessary parameters
http://www.shoutmeloud.com/google-webmaster-tool-added-url-parameter-option-seo.html

How to get such header title and search input in Google search for website

How to get such header title and search input in Google search for website like below:
I am doing my website with core PHP (not any CMS like WordPress, Drupal etc.). So please help me to get such a result in Google.
This is called Sitelinks.
Check it out here: https://support.google.com/webmasters/answer/47334?hl=en
It's an Google automated process and you can't do much to control it. Although a google search on "how to get sitelinks" gives you plenty of results on how to get them, for example, here, or here.
Or perhaps you can purchase them under your AdWords advertisement.
As far as I know, it is much related to PHP. It's more on Search Engine Optimization (SEO).

Accessing full url of all page images Wikipedia API

I'm experimenting with the Wikipedia API and was trying to get the full urls for all images on a particular page, in this example Google's main page (http://en.wikipedia.org/wiki/Google).
I found the page id through the use of another API and then attempted to use this information in the following API to get the full urls of all images on that page:
http://en.wikipedia.org/w/api.php?action=query&pageids=1092923&generator=images&prop=imageinfo&iiprop=url|dimensions|mime&format=xml
I get some of the page images from this but cannot understand why I am not getting all - specifically the logo which is what I was most interested in. Apologies I am aware that there are similar questions which have been asked but I was not able to find one which would assist me here.
The API does not give you all results at once, it defaults to 10 results. You see in the beginning answer that you have a value for the parameter gimcontinue. If you use it like this you get more images: http://en.wikipedia.org/w/api.php?action=query&pageids=1092923&generator=images&prop=imageinfo&iiprop=url|dimensions|mime&format=xml&gimcontinue=1092923|Google_bike.jpg
Alternatively, you can ask for more images at once using gimlimit like this: http://en.wikipedia.org/w/api.php?action=query&pageids=1092923&generator=images&prop=imageinfo&iiprop=url|dimensions|mime&format=xml&gimlimit=500

Number of results from CSE do not match google total results number

In Google Custom Search Engine if I make a search like this:
https://www.googleapis.com/customsearch/v1?key={$apikey}&q=####KEYWORD#####&cref={$cref}&alt=json
with my $apikey and my $cref I get a json results that do not match with the results of google via browser.
I've configured my search engine to search all the web as described here but I've noticed that many results are missing, for example the ones from forums.
Is there a way to specify to CSE to search also the forums? I want to use the same results as google classic search.