【发布时间】:2012-03-17 07:48:01
【问题描述】:
我正在尝试从网站下载 HTML 文件。我正在使用以下简单的方法:
URL url = new URL("here goes the link to the html file");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String htmlfile = "";
String temp;
while ((temp = br.readLine()) != null) {
htmlfile+= temp;
}
问题是我在 htmlfile 变量中得到以下字符串:
The installation of ... requires the acceptance of a cookie by your browser
software. The cookie is used to ensure that you and only you are
able to access information ....
换句话说,我需要在从 url 打开流时启用 cookie。是否可以通过使用 URL 来实现这一点,还是我需要不同的方法?提前致谢
【问题讨论】: