我想通過Java中的URL獲取HTML。但是301 Moved Permanently
就是我所擁有的。另一個URL可以工作。怎麼了?這是我的代碼:301永久移動
hh= new URL("http://hh.ru");
in = new BufferedReader(
new InputStreamReader(hh.openStream()));
while ((inputLine = in.readLine()) != null) {
sb.append(inputLine).append("\n");
str=sb.toString();//returns 301
}
如果另一個URL的作品,所以沒有任何事情你的代碼錯誤,是http://hh.ru有效的網址? – Soosh
當我訪問該URL時,我得到一個301重定向。這裏是一個鏈接到重定向後面的代碼:http://stackoverflow.com/questions/1884230/java-doesnt-follow-redirect-in-urlconnection – dcaswell