HTMLUnit不处理jsonp请求

时间:2022-12-06 21:23:30

I am trying to crawl my GWT app with HTMLUnit, but for a certain page the desired content is not returned. The GWT page contains a dynamically added javascript which makes a jsonp request to a gae server. I already debugged the server code, and the breakpoint is hit, but at this time the htmlunit code is already finished and the returned content is not complete.

我正在尝试使用HTMLUnit抓取我的GWT应用程序,但是对于某个页面,不会返回所需的内容。 GWT页面包含一个动态添加的javascript,它向gae服务器发出jsonp请求。我已经调试了服务器代码,并且命中了断点,但此时htmlunit代码已经完成并且返回的内容未完成。

I almost tried all suggested solutions available in *, but without any success.

我几乎尝试了*中提供的所有建议的解决方案,但没有任何成功。

Here is the jsonp request.

这是jsonp请求。

http://30.tripstorekrabi.appspot.com/activity?&callback=__gwt_jsonp__.P0.onSuccess

On other pages I use exactly the same kind of call, and there it works fine.

在其他页面上,我使用完全相同的调用,并且它工作正常。

Can anyone help me?

谁能帮我?

1 个解决方案

#1


0  

I found a workaround in my GWT code:

我在GWT代码中找到了一个解决方法:

Now the jsonp request is executed in a deferred scheduled command:

现在,jsonp请求在延迟的调度命令中执行:

 Scheduler.get().scheduleDeferred(new ScheduledCommand() {
  @Override
  public void execute() {
    activityRegistry.loadActivities(new AsyncCallback<Result>() {
  }

Now the javascript function is processed from htmlunit and the desired content is showed.

现在从htmlunit处理javascript函数并显示所需的内容。

#1


0  

I found a workaround in my GWT code:

我在GWT代码中找到了一个解决方法:

Now the jsonp request is executed in a deferred scheduled command:

现在,jsonp请求在延迟的调度命令中执行:

 Scheduler.get().scheduleDeferred(new ScheduledCommand() {
  @Override
  public void execute() {
    activityRegistry.loadActivities(new AsyncCallback<Result>() {
  }

Now the javascript function is processed from htmlunit and the desired content is showed.

现在从htmlunit处理javascript函数并显示所需的内容。