http请求有两种方式给出另一种结果,一种是java代码,另一种是从网站复制元素。
我正在努力使他们达到同样的结果!当我使用java代码时
private static boolean isValid(URL url, HttpURLConnection connection) {
BufferedReader reader;
String line;
StringBuffer responseContant = new StringBuffer();
try {
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(4000);
connection.setReadTimeout(4000);
int status = connection.getResponseCode();
if (status > 299) {
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
while ((line = reader.readLine()) != null)
responseContant.append(line);
reader.close();
} else {
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((line = reader.readLine()) != null)
responseContant.append(line);
reader.close();
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
它给了我另一个值,而不是使用inspect>copy>copy元素怎么可能呢?如何解决这个问题?
谢谢你们!!
暂无答案!
目前还没有任何答案,快来回答吧!