开发者

Download html page source code using GWT

I am trying to use GWT to download the source code of web pages, but i do not know where to开发者_JS百科 start, can anyone gives me some key word that i can search on google, or gives me some links from tutorials.

Thanks!!


In JavaScript, this is typically done with an XMLHttpRequest. GWT's analog to XMLHttpRequest is RequestBuilder, which can be used like so:

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
  }
});


Some GWT manual about cross-site scripting https://developers.google.com/web-toolkit/doc/latest/tutorial/Xsite

And here some discussion about using RequestBuilder and JSNI GWT RequestBuilder - Cross Site Requests

As alternative you can do a page download on the server-side...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜