2010-04-21 293 views
0

我想用GWT下載網頁的源代碼,但我不知道從哪裏開始,任何人都可以給我一些關鍵詞,我可以在谷歌上搜索,或給出我從教程的一些鏈接。使用GWT下載html頁源代碼

謝謝!

回答

1

在JavaScript中,這通常使用XMLHttpRequest完成。 GWT的模擬XMLHttpRequestRequestBuilder,可以使用像這樣:

new RequestBuilder("GET", "http://example.com/page.html").sendRequest("", new RequestCallback() { 
    @Override 
    public void onResponseReceived(Request request, Response response) { 
    String src = response.getText(); 
    // do things with the source 
    } 
    @Override 
    public void onError(Request request, Throwable throwable) { 
    // handle the error 
    } 
});