开发者

Download html page source code using GWT

开发者 https://www.devze.com 2022-12-27 10:38 出处:网络
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 fr

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

精彩评论

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