public static String readHtml(String myurl) { StringBuffer sb = new StringBuffer(""); URL url; try { url = new URL(myurl); BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), "gbk")); String s = ""; while ((s = br.readLine()) != null) { sb.append(s + "\r\n"); } } catch (Exception e) { e.printStackTrace(); } return sb.toString(); }
上面代码中的gbk编码是指网页的编码,如果使其它编码,请自行修改~
然后调用parse方法:
Document document = Jsoup.parse(readHtml("xxxxx/webroot/showarticle.php?pid=1&cid=1045&aid=1362"), "xxxxx/");
你再试试有没有乱码。