GSA key words to URLs through JAVA code

93 views Asked by At

Hello I want to specify a keyword to a particular URL through java code.

Please suggest the approach how should I go about it.

1

There are 1 answers

3
Mohan kumar On

Please find the below code which I was using to get the GSA response for the given keyword.

                        String gsaUrl = "http://yourAppliance/search?q=search keyword&client=default_frontend&output=xml_no_dtd&proxystylesheet=default_frontend&oe=UTF-8&ie=UTF-8&ud=1&ulang=en&filter=0&site=default_collection&entqr=3&entqrm=3&num=20&start=0";
                        BufferedReader in = null;                       
                        URL url = new URL(gsaUrl);
                        URLConnection conn = url.openConnection();
                        in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                        String inputLine;
                        StringBuffer gsaJsonResponse = new StringBuffer();

                        while ((inputLine = in.readLine()) != null) {
                            gsaJsonResponse.append(inputLine);
                        }

Take care of exception and closing of stream. Hope it helps.