With the Web Search API, there are two parameters that you need to get more 
results. The first is rsz, which you can set to any number up to 8 (10 if 
you're using a CSE), and the second is start, which you can use to get 
additional "pages" of results. For example, if your rsz is set to 8, set start 
to 8 to retrieve page 2, 16 to retrieve page 3, 24 to retrieve page 4, etc.

That said, you can only retrieve up to 64 results total - across 8 separate 
requests for 8 results each - from the Web Search API. And they will not be 
exactly the same results that you would retrieve from google.com. More 
specifically, the API will drop a number of results as a deterrent to SEO 
applications.

Speaking of which, the only reason I can think of that you would need ALL of 
the results would be for SEO purposes, which would probably also involve 
automated queries. Robots, spiders, retrieval applications, etc., which submit 
automated queries are prohibited in the TOS. If this is what you're up to, 
you're going to want to review the TOS before proceeding.

Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA

For more information or a project quote:
[email protected]

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!

On Apr 29, 2011, at 2:00 AM, dlopez wrote:

> Hello
> 
> I'm triying to use Google Search API with Java, i have correct key but
> the query only return my 4 results.
> 
> For example:
> 
> https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=HELLOWORLD&key=MYKEY
> 
> ¿How can i obtain all results?
> 
> I do this in Java:
> 
>        URL url = new URL(
>                            "https://ajax.googleapis.com/ajax/services/
> search/web?" +
>                            "v=1.0&q=HELLOWORLD" +
>                            "&key=" + sMyKey
>                         );
> 
>        URLConnection connection = url.openConnection();
>        connection.addRequestProperty("Referer", "http://
> fake.sisob.es/");
> 
>        String line;
>        StringBuilder builder = new StringBuilder();
>        BufferedReader reader =
>        new BufferedReader(new
> InputStreamReader(connection.getInputStream()));
>        while((line = reader.readLine()) != null) {
>         builder.append(line);
>        }
> 
>        JSONObject json = new JSONObject(builder.toString());
>        JSONArray ajson = (JSONArray)
> ((JSONObject)json.get("responseData")).get("results");
> 
>        for(int i = 0; i < ajson.length(); i++)
>        {
> 
> System.out.println(((JSONObject)ajson.get(i)).get("url").toString());
>        }
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google AJAX APIs" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-ajax-search-api?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-ajax-search-api?hl=en.

Reply via email to