search word in google and want to find hits of each word using java program

前端 未结 5 950
走了就别回头了
走了就别回头了 2021-01-27 11:42

I have 30000 dictionary words. In that I want to to search each word in Google and want to find hits of each word using Java program. Is it possible?

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-27 12:26

    Reading from a url with java is pretty straight forward. A basic working example is as follows

    public Set readUrl(String url) {
    
            String line;
            Set lines = new HashSet();
    
            try {
                URL url = new URL(url);
                URLConnection page = url.openConnection();
    
                BufferedReader in = new BufferedReader( new InputStreamReader(page.getInputStream()));
    
                while ((line = in.readLine()) != null) {
                    lines.add(line);
                }
    
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return lines;
        }
    

提交回复
热议问题