【问题标题】:phantomjs and ajax requestphantomjs 和 ajax 请求
【发布时间】:2014-02-03 12:17:00
【问题描述】:

我正在玩一些 phantomjs 和 coffeescript,在访问他的页面中已经有 jquery 的网站后,我想要实现的是触发一些 ajax get 请求,这些请求应该 把数据还给我。我玩过一些 Firefox 控制台,效果非常好。不幸的是,phantomjs 什么也没返回,我也不知道为什么。

page = require('webpage').create()
system = require 'system'

url = 'http://www.testpage.com'
#page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js")
page.open url,
  (status) ->
    if status isnt 'success'
      console.log 'uanble to acces the netzwprk'
    else
      results = page.evaluate ->
        all = []
        list = $(".navigation .main")
        for item in list
          all.push(item.href)
        #return all
          $.get item.href, (data,status) ->
            console.log data.toSource()

      #console.log results.join('\n')
    phantom.exit()

谢谢。求帮助。

xaver

【问题讨论】:

    标签: jquery ajax coffeescript


    【解决方案1】:

    我认为这是因为您必须等待 phantomjs 完成页面加载。你可以看到一些提示:https://code.google.com/p/phantomjs/issues/detail?id=265

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      • 2013-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 2016-05-05
      相关资源
      最近更新 更多