0
HTMLテーブルからデータを取得しようとしていますが、Webサイトに接続しているときにブラウザに表示されている情報が返されません。ページからの予期しない結果
これは私がHTMLの結果を見て、取得するために期待していものです。ここで
<div id=ResultsContainer>
<p class=RedBold10pt>Search returned no matches</p>
</div>
は私のJavaコード
です:<div id="ResultsContainer">
<div id="Pagination"><div class="left">displaying: 601 - 633 of 633</div><div class="right">
...
、ここでは私が取得していますものです
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);
この原因は何ですか?
ブラウザから送られたリクエストは、あなたのJavaアプリケーションから送信されたリクエストのようでした。両方のリクエストが同じかどうかを確認するには、fiddlerのようなアプリケーションを使用します。 –
URLにハッシュタグがある可能性があります。http://stackoverflow.com/questions/4251841/400-error-with-httpclient-for-a-link-with-an-anchor –