回答
你將不得不自己下載頁面,並自己解析所有信息。
你可能想看看Pattern
類,看看一些regex
,和URL
和String
類將是非常有用的。
您可以隨時下載一個html庫以使其更容易。可能是類似http://htmlparser.sourceforge.net/。
非常一般的問題很明顯,我不能提供相關的代碼,但這被稱爲刮。
我必須下載它或有任何方法只是發送http請求? – user2051347 2013-03-14 07:30:58
@ user2051347您可以請求任何您想要的信息,但它不會奇蹟般地出現在您的數據中。我不確定你在問什麼。 – Austin 2013-03-14 07:31:35
我的意思是,我只是發送和HTTP請求,並返回HTML頁面,只是在代碼中搜索關鍵字,而沒有真正下載頁面。 – user2051347 2013-03-14 07:33:54
嗯,這是你如何從頁面的所有內容
那麼,只要你想
package farzi;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
public class GetXMLTask
{
public static void main(String args[])
{
try
{
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://derstandard.at/anzeiger/immoweb/Suchergebnis.aspx?Regionen=9&Bezirke=&Arten=&AngebotTyp=×tamp=1363245585829");
HttpResponse response;
StringBuilder builder= new StringBuilder();
response = httpClient.execute(httpPost);
System.out.println(response.toString());
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
char[] buf = new char[1000];
int l = 0;
while (l >= 0)
{
builder.append(buf, 0, l);
l = in.read(buf);
}
System.out.println(builder.toString());
}
catch (URISyntaxException e) {
System.out.println("URISyntaxException :"+e);
e.printStackTrace();
}
catch (HttpException e) {
System.out.println("HttpException :"+e);
e.printStackTrace();
}
catch (InterruptedException e) {
System.out.println("InterruptedException :"+e);
e.printStackTrace();
} catch (IOException e) {
System.out.println("IOException :"+e);
e.printStackTrace();
}
}
}
- 1. 從網站獲取數據
- 2. 從網站獲取數據
- 3. 從網站獲取數據
- 4. 從網站沒有網址獲取數據
- 5. 如何在沒有API的情況下從網站獲取數據
- 6. Android沒有從網站獲取數據到ArrayList
- 7. 從網站獲取的數據
- 8. 從其他網站獲取的數據
- 9. 請求 - 從基於api的網站獲取數據
- 10. 如何獲取一個開放api網站的所有數據
- 11. android-get從網站獲取數據
- 12. 無法從網站獲取數據
- 13. 鉻擴展從網站獲取數據
- 14. 從XML網站獲取數據
- 15. 從網站HTML表單獲取數據
- 16. Android - 從網站獲取數據
- 17. 從外部網站獲取xml數據
- 18. Excel VBA - 從網站獲取數據
- 19. 從給定網站獲取數據
- 20. 從外部網站獲取JSON數據
- 21. 無法從網站獲取數據
- 22. 如何從網站獲取DOM數據
- 23. 從獲取數據wikisource.org網站
- 24. Python從網站獲取數據
- 25. Python從安全網站獲取數據
- 26. 從其他網站獲取數據
- 27. 從網站獲取數據返回excel
- 28. 從其他網站獲取數據表
- 29. 獲取網站集中的所有網站而沒有獲取所有列表?
- 30. 從網站API獲取JSON數據POST請求
你要使用的搜索詞是「網絡抓取」可以解析的頁面數據。 – 2013-03-14 07:27:16
看看這個http://stackoverflow.com/questions/2861/options-for-html-scraping – 2013-03-14 07:27:44
如果我使用這樣的軟件包,服務器是否會受到限制? – user2051347 2013-03-14 07:28:39