java 抓取网页源文件。
要求抓到的串和在浏览器中查看源文件是相同的。(js要解析过的。)http://dl.
public String downww (String st){
String str = "";
String s = "";
StringBuffer sb = new StringBuffer();
BufferedReader br = null;
try {
URL u =new URL(st);
HttpURLConnection huc =(HttpURLConnection) u.openConnection();
InputStream in = huc.getInputStream();
br = new BufferedReader(new InputStreamReader(in));
while ((s = br.readLine()) != null)
{
str += s;
}
br.close();
huc.disconnect();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
}
return str;
}