Pregunta

I'm trying to write a Java program that uses Google's Custom Search API to retrieve search results. As a first-time user of API's, though, the documentation on the website is extremely confusing - does one retrieve results by connecting to the google api link like:

Google Custom Search API

(Then once you've connected, how do you display the results? Using BufferedReader gives me a 403 error)

...or do you need to download the library and use their GoogleCustomSearch class like:

java google custom search api

? I have the googleux-customsearch jar (from http://blog.lux-medien.com/2011/08/google-custom-search-java-implementation/) and integrated it into Eclipse but I'm not quite sure what import statements I should be using to use these classes (again, first-time user).

I'm also not quite sure the distinction between the Java client, REST API, and JSON API (are they all the same thing??) as detailed on the Google Custom Search API website...can anyone please clarify? Thanks!

¿Fue útil?

Solución

It is true the docs are quite confusing at the moment.

There are 2 version of Google Custom Search: free (CSE - Custom Search Engine) and paid (GSS - Google site Search).

When using the free one you have 2 options: + implement javascript widget with search box and placeholder for results: https://developers.google.com/custom-search/docs/element - this is a standard way of implementing CSE + use JSON REST api - https://developers.google.com/custom-search/v1/overview - this is experimental feature and has a limited free quota (100 queries as of now)

When using GSS (paid one), you can still use javascript widget, but additionally you get access to XML results: https://developers.google.com/custom-search/docs/snippets#presentation_layer

Ususally first you create a search engine in the Control Panel: http://www.google.com/cse and then you use either js widget to access it or JSON (free but low quota) or XML (paid) feeds via HTTP GET requests from your website.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top