[英]Can't download html
I'm trying to download this html 我正在尝试下载此html
I'm using this code: 我正在使用此代码:
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());
UPDATED: ASLO tried to use it: 更新: 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);
again responce like this one: 再次像这样回应:
<html>
<body>
<script>document.cookie="BPC=f563534535121d5a1ba5bd1e153b";
document.location.href="http://...link.../all?attempt=1";</script>
</body>
</html>
I can't find any solution... Page can not be downloaded maybe because haven't cookie ... or what? 我找不到任何解决方案...无法下载页面,可能是因为没有cookie ...还是什么?
In the script tag, you have this statement : 在脚本标记中,您具有以下语句:
document.location.href="....link..../all?attempt=1";
Normally it forces the browser to reload the page with the location. 通常,它会强制浏览器使用该位置重新加载页面。 I think it's the page "....link...?attempt=1" that you want to download in fact. 我认为实际上是您要下载的页面“ .... link ...?attempt = 1”。
It is not sure that it will work anyway if you don't use the cookie defined in the script but it deserves a try. 如果您不使用脚本中定义的cookie,则不确定它是否仍然可以工作,但是值得尝试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.