Java PC中的URL源代码不';在电话HTTP中不匹配
使用此URL: 当我在我的PC网络浏览器中检查视图源时,我可以找到og:type likeJava PC中的URL源代码不';在电话HTTP中不匹配,java,html,http,twitter,Java,Html,Http,Twitter,使用此URL: 当我在我的PC网络浏览器中检查视图源时,我可以找到og:type like <meta property="og:title" content="CNN on Twitter"> Web服务器可以为不同的用户代理提供不同的内容。那么,有没有什么技巧可以使我的电话输入流代理与PC代理中的相同?没有什么技巧。在创建URLConnection时,可以传递所有类型的头。 String urlContent = ""; try { Syste
<meta property="og:title" content="CNN on Twitter">
Web服务器可以为不同的用户代理提供不同的内容。那么,有没有什么技巧可以使我的电话输入流代理与PC代理中的相同?没有什么技巧。在创建
URLConnection
时,可以传递所有类型的头。
String urlContent = "";
try {
System.out.println("I'm trying to connect");
URL urlCon = new URL(urlStr);
HttpURLConnection con = (HttpURLConnection) urlCon
.openConnection();
System.out.println("Ok im here ");
con.setReadTimeout(6000);
if (con.getResponseCode() == 200) {
System.out.println("Page is ok!");
urlContent = readStream(con.getInputStream());
return urlContent;
} else {
return urlContent;
}
} catch (UnknownHostException e){
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return urlContent;
}