zoukankan      html  css  js  c++  java
  • 根据链接获取网页内容

    public static String getContent(String strUrl) throws Exception {
            try {
                URL url = new URL(strUrl);
                BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));
                String s = "";
                StringBuffer sb = new StringBuffer("");
                while ((s = br.readLine()) != null) {
                    sb.append(s);
                }

                br.close();
                return sb.toString();
            } catch (Exception e) {
                System.out.println("can't open url:"+strUrl);
                throw e;
            }
        }

  • 相关阅读:
    LeetCode 55
    LeetCode 337
    LeetCode 287
    LeetCode 274
    LeetCode 278
    LeetCode 264
    LeetCode 189
    LeetCode 206
    LeetCode 142
    LeetCode 88
  • 原文地址:https://www.cnblogs.com/IT-shen/p/3944536.html
Copyright © 2011-2022 走看看