当使用
HttpURLConnection uConnection = (HttpURLConnection) u.openConnection(); uConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
访问时
uri.add("https://www.tibet3.cn/news/international/2017-08-14/21744.html");
uri.add("http://www.tibet3.cn/news/international/2017-08-14/21744.html");
两个同样的地址,不同http和https造成的,
http是协议,https是以安全为目标的HTTP通道,简单讲是HTTP的安全版,
html>head><title>301 Moved Permanently</title></head>body bgcolor="white">center><h1>301 Moved Permanently</h1></center>hr><center>nginx</center>/body>/html>
程序openConnection()请求时没有加s,浏览器访问时正常的原因是自动加了s,所以看起来很正常。不马虎就找到毛病了。