Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么不是';t Ghost.py加载/运行我的Javascript?_Javascript_Python_Requirejs_Ghost.py - Fatal编程技术网

为什么不是';t Ghost.py加载/运行我的Javascript?

为什么不是';t Ghost.py加载/运行我的Javascript?,javascript,python,requirejs,ghost.py,Javascript,Python,Requirejs,Ghost.py,Ghost.py应该运行JS: require.js是通过http获取的,但据我所知,它没有运行,因为“js/main.build”永远不会获取,它指定的js文件也不会加载。这一切在真正的浏览器中都能完美运行 In [51]: ghost = Ghost(wait_timeout=60) In [52]: page, resources = ghost.open(url) In [53]: [r.url for r in resources] Out[53]: [PyQt4.QtCore.

Ghost.py应该运行JS:

require.js是通过http获取的,但据我所知,它没有运行,因为“js/main.build”永远不会获取,它指定的js文件也不会加载。这一切在真正的浏览器中都能完美运行

In [51]: ghost = Ghost(wait_timeout=60)

In [52]: page, resources = ghost.open(url)

In [53]: [r.url for r in resources]
Out[53]: 
[PyQt4.QtCore.QUrl(u'https://example.com/#consume/283e6571bcecf34143cbd60f35e0464b'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/ui.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/colorpicker.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/selectize.default.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/datepicker.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/site.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/jquery.fileupload-ui.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/style.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/bootstrap.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/css/redactor.css'),
 PyQt4.QtCore.QUrl(u'https://example.com/js/lib/require.js')]

In [54]: ghost.con
ghost.confirm  ghost.content  

In [54]: ghost.content
Out[54]: u'<!DOCTYPE html><html lang="en"><head>\n    <meta charset="utf-8">\n    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n    <title>Ving</title>\n\n    <link rel="stylesheet" href="css/ui.css">\n    <link rel="stylesheet" href="css/bootstrap.css">\n    <link rel="stylesheet" href="css/colorpicker.css">\n    <link rel="stylesheet" href="css/redactor.css">\n    <link rel="stylesheet" href="css/site.css">\n    <link rel="stylesheet" href="css/selectize.default.css">\n    <!-- My Bug fixes / overrides to work with real app -->\n    <link rel="stylesheet" href="css/style.css">\n    <link rel="stylesheet" href="css/datepicker.css">\n    <!-- Theme for uploader -->\n    <link rel="stylesheet" href="css/jquery.fileupload-ui.css">\n    <!-- Shims for IE support  -->\n    <!--[if lte IE 8]>\n      <script src="js/lib/html5shiv.js"></script>\n      <script src="js/lib/r2d3.min.js" charset="utf-8"></script>\n    <![endif]-->\n  </head>\n\n  <body>\n    <div id="wrapper">\n      <header id="header" class="container"></header>\n      <div id="content" class="container"></div>\n    </div>\n    <footer id="footer" class="container"></footer>\n    <div id="modal" class="modal modal-box hide fade"></div>\n    <script data-main="js/main.built" src="js/lib/require.js"></script>\n\n  \n\n</body></html>'

In [55]:
[51]中的
ghost=ghost(等待超时=60)
在[52]:页面中,resources=ghost.open(url)
在[53]中:[参考资料中r的r.url]
出[53]:
[PyQt4.QtCore.QUrl(u'https://example.com/#consume/283e6571bcecf34143cbd60f35e0464b'),
PyQt4.QtCore.QUrl(u'https://example.com/css/ui.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/colorpicker.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/selectize.default.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/datepicker.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/site.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/jquery.fileupload-ui.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/style.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/bootstrap.css'),
PyQt4.QtCore.QUrl(u'https://example.com/css/redactor.css'),
PyQt4.QtCore.QUrl(u'https://example.com/js/lib/require.js')]
在[54]中:ghost.con
ghost.confirm ghost.content
在[54]中:ghost.content
Out[54]:u'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
在[55]中:
我还尝试加载“”:

[7]中的
:url='1〕https://mail.google.com/'
在[8]中:ghost=ghost(等待超时=60)
在[9]:页面中,resources=ghost.open(url)
在[10]中:ghost.content
Out[10]:u“
在[11]中:

当require.js异步加载内容时,您必须等待自定义条件,例如:

g = Ghost()
g.open(url, wait=False)
page, resources = g.wait_for_text('something made by require.js')

尝试从python程序而不是从ipython或其他交互式提示符运行ghost。这似乎是ghost或qt的一个问题。

您找到解决方案了吗?没有,所以我刚切换到PhantomJS。在Python中工作会很好,但是哦,好吧。JS在哪个浏览器上工作正常?Firefox、Chrome、IE。我尝试了其他带有JS的页面,但这些都不起作用。问题是JS从未执行过。等等,我不喜欢文本()。
g = Ghost()
g.open(url, wait=False)
page, resources = g.wait_for_text('something made by require.js')