`

抓取网页

阅读更多

public static String getHtmlByUrl(String url) throws IOException {

URL htmlUrl = new URL(url);

BufferedReader reader = new BufferedReader(new InputStreamReader(htmlUrl.openStream()));

String temp = "";

StringBuffer sb = new StringBuffer();

while((temp = reader.readLine())!= null) {

sb.append(temp);

}

return sb.toString();

}

 

简单实现下, 抓取还得用框架

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics