2012-04-07 52 views
0

我試圖從HTML表格中獲取數據,但是當我連接到網站時,它並未返回它在瀏覽器中顯示的內容。頁面出現意外結果

這就是我期待通過查看HTML結果得到:

<div id="ResultsContainer"> 
    <div id="Pagination"><div class="left">displaying: 601 - 633 of 633</div><div class="right"> 
... 

這裏就是我得到:

<div id=ResultsContainer> 
     <p class=RedBold10pt>Search returned no matches</p> 
</div> 

這裏是我的Java代碼

HttpClient client = new DefaultHttpClient(); 

HttpGet request = new HttpGet(); 
request.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.15 Safari/536.5"); 
request.setURI(new URI("http://results.active.com/pages/searchform.jsp?posted_p=t&numPerPage=50&page=0&rsID=10505&queryType=division#VIEW")); 
HttpResponse response = client.execute(request); 

BufferedReader in = null; 
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); 
StringBuffer sb = new StringBuffer(""); 
String line = ""; 
String NL = System.getProperty("line.separator"); 

while ((line = in.readLine()) != null) { 
    sb.append(line + NL); 
} 
in.close(); 
String page = sb.toString(); 
System.out.println(page); 

這可能是什麼原因造成的?

+1

從瀏覽器發送的請求顯然與您的java應用程序發送的請求不一樣。使用像fiddler這樣的應用程序來查看兩個請求是否相同。 – 2012-04-07 20:18:40

+1

它可能是URL上的哈希標記:請參閱http://stackoverflow.com/questions/4251841/400-error-with-httpclient-for-a-link-with-an-anchor – 2012-04-07 20:54:40

回答

0

問題出在Google AppEngine上。我必須從1.6.4降級到1.6.3