答案 0 :(得分:1)
您将不得不自己下载页面,并自行解析所有信息。
您可能希望查看Pattern
课程,查看一些regex
,URL
和String
课程非常有用。
您可以随时下载html库以简化操作。像http://htmlparser.sourceforge.net/这样的东西。
很一般的问题很明显我无法提供相关的代码,但这被称为抓取。
答案 1 :(得分:0)
这就是你从页面获取所有内容的方式
然后您可以根据需要解析页面数据
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();
}
}
}