0
嗨,我是Java網絡包的新手。問題通過HttpURLConnection訪問HTTP網站
極品: 我想訪問某個特定的網頁,並且需要獲得頁面的HTML內容通過Java code.I使用HttpURLConnection類訪問的URL。
該網站的問題: 我得到的403響應代碼爲該特定的網站,而當我能夠訪問其他網站具有相同的代碼。有關該問題的網站
詳情: 有問題的網站是一個HTTP網站,當從Web瀏覽器訪問手動,我能夠訪問該網頁&能夠訪問該網頁的HTML內容。
有問題的URL: http://redbus2us.com/h1b-visa-sponsors/index.php?searchText=a&searchYear=14&action=search&pn=2
正常工作網址: http://www.mkyong.com/all-tutorials-on-mkyong-com/
代碼:
String base_url="http://redbus2us.com/h1b-visa-sponsors/index.php?searchText=a&searchYear=14&action=search&pn=",full_url;
int end_url=1;
try
{
for(;end_url<36302;end_url++)
{
full_url=base_url+end_url;
URL url=new URL(full_url);
HttpURLConnection url_connect=(HttpURLConnection)url.openConnection();
System.out.println(url+","+url_connect.getResponseCode());
}
}
請建議我是否有我的代碼或問題與問題特定的網站。