【发布时间】:2014-01-24 09:49:22
【问题描述】:
我正在尝试下载此 html
我正在使用此代码:
Document doc = null;
try {
doc =Jsoup.connect(link).userAgent("Mozilla").get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i ("html", doc.toString());
更新: ASLO 尝试使用它:
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(link);
HttpResponse response = null;
try {
response = client.execute(request);
} catch (ClientProtocolException e1) {
//
e1.printStackTrace();
} catch (IOException e1) {
//
e1.printStackTrace();
}
InputStream in = null;
try {
in = response.getEntity().getContent();
} catch (IllegalStateException e1) {
//
e1.printStackTrace();
} catch (IOException e1) {
//
e1.printStackTrace();
}
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
} catch (UnsupportedEncodingException e) {
//
e.printStackTrace();
}
StringBuilder str = new StringBuilder();
String line = null;
try {
while((line = reader.readLine()) != null)
{
str.append(line);
}
} catch (IOException e1) {
//
e1.printStackTrace();
}
try {
in.close();
} catch (IOException e1) {
//
e1.printStackTrace();
}
String html = str.toString();
Log.e("html", html);
再次像这样回复:
<html>
<body>
<script>document.cookie="BPC=f563534535121d5a1ba5bd1e153b";
document.location.href="http://...link.../all?attempt=1";</script>
</body>
</html>
我找不到任何解决方案...页面无法下载可能是因为没有cookie...或什么?
【问题讨论】:
-
需要更多信息。 “使用此代码” - 为了什么?那是什么语言?看起来像一些 Javascript,但话又说回来......它没有。
-
@Snorlax java 和 android 查看标签
-
是的,我明白了。它仍然没有意义。 “尝试下载此 html”是什么意思 - 您是否尝试使用 Java 显示它?您是否尝试使用 Java 将其下载并存储在 SDCard 上?
-
@Snorlax 将本页的资源下载到字符串
标签: java android html download jsoup