public static String getWiki(String inputString, HashMap<String, String> data) throws MalformedURLException, IOException  {
//        StringBuffer inputSb = new StringBuffer(inputString);
        
        String parsedText = inputString.trim().replaceAll("\\s+", "%20");
        if(parsedText.length() == 0)
            return "";

        URL wikiURL = new URL("http://www.google.com/search?btnI=I'm+Feeling+Lucky&q=" + parsedText + "%20site%3Aen.wikipedia.org");
        
        HttpURLConnection connection = (HttpURLConnection) wikiURL.openConnection();
        connection.addRequestProperty("User-Agent", "Mozilla/4.76");
        connection.setConnectTimeout(15000);
        connection.setReadTimeout(15000);
        connection.setInstanceFollowRedirects(true);
        connection.connect();

                
        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); //oracle.openStream()
        
        String inputLine;

        StringBuilder sb = new StringBuilder();
        while ((inputLine = in.readLine()) != null) {
            sb.append(inputLine);
//            System.out.println(inputLine);
        }
        
        String text = sb.toString();

        int start = 0;
        int end = 0;
        
//        Pattern p = Pattern.compile("<\\s*body[^>]+>",Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
        Pattern p = Pattern.compile("<!--\\s*bodycontent\\s*-->", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
        Matcher m = p.matcher(text);
        while(m.find(start))
        {
            start = m.end();
        }
        
//        p = Pattern.compile("<\\s*/\\s*body\\s*>", Pattern.CASE_INSENSITIVE);
        p = Pattern.compile("<!--\\s*/bodycontent\\s*-->", Pattern.CASE_INSENSITIVE);
        m = p.matcher(text);
        if(m.find(start))
        {
            end = m.start();
        }
        
        text = text.substring(start, end);
        
        String tagRegex = "</?\\w+(\\s+\\w+\\s*=\\s*('[^']*'|\"[^\"]*\"))*\\s*/?>?";
        //remove table of content
        text = text.replaceAll("(?s)<table\\s+id=(\"|')toc(\"|').*?</\\s*table>", " ");
        text = text.replaceAll("(?s)<a\\s+href=(\"|')#cite.*?</\\s*a>", " ");
        text = text.replaceAll("(?s)<span\\s+class=(\"|')editsection.*?</\\s*span>", " ");
        text = text.replaceAll("(?s)<div\\s+class=(\"|')dablink.*?</\\s*div>", " ");
        text = text.replaceAll("(?s)<div\\s+class=(\"|')rellink.*?</\\s*div>", " ");
        //text = text.replaceAll("(?s)<div\\s+class=(\"|')thumb.*?</\\s*div>", " ");
        text = text.replaceAll("(&#160;|&nbsp;)", " ");
        text = text.replaceAll("(?s)<div\\s+class=(\"|')reflist.*$","");
        
        if(data != null)
        {
            //substract infograph
            p = Pattern.compile("<table\\s+class=\"infobox.*?</table>",Pattern.DOTALL);
            m = p.matcher(text);
            String infoBox = "";
            if(m.find())
            {
                infoBox = m.group();
                //Substract Data
//                p = Pattern.compile("<tr.*?>\\s*<t(d|h).*?>(.*?)</t(d|h)>\\s*<td.*?>(.*?)</td>\\s*</tr>");
                p = Pattern.compile("<tr.*?>(.*?)</tr>");
                m = p.matcher(infoBox);
                Pattern p2 = Pattern.compile("\\s*<t(d|h).*?>(.*?)</t(d|h)>\\s*<td.*?>(.*?)</td>\\s*");
                Matcher m2;
                int endRows = 0;
                String row = "";
                while(m.find(endRows))
                {
                    row = m.group(1);
                    m2 = p2.matcher(row);
                    if(m2.find())
                    {
                        String k = m2.group(2).replaceAll(tagRegex, "");
                        String v = m2.group(4).replaceAll(tagRegex, "");
                        data.put(k, v);
                    }
                    
                    endRows = m.end();
                }

            }
            if(infoBox.length() >0)
                text = text.replace(infoBox, " ");
        }
        
        text = text.replaceAll(tagRegex," ").replaceAll("<!--[^>]+>", " ").replaceAll("\\s+", " "); 
//        text = text.replaceAll("<!--[^>]+>", " ").replaceAll("\\s+", " ");
        
        return text;
    }