vin*_*ini 5 phantomjs casperjs
我通过npm在我的windows machina上安装了casperjs和phantomjs.但是我得到了这个问题.
C:\>casperjs sample.js
C:\>Unable to open file: sample.js
Unsafe JavaScript attempt to access frame with URL about:blank from frame
with URL file:///C:/Users/vini/AppData/Roaming/npm/node_modules/casperjs/bin/bootstrap.js.
Domains, protocols and ports must match.
Run Code Online (Sandbox Code Playgroud)
Art*_* B. 10
这是CasperJS和PhantomJS的1.9.8版本的已知问题.它没有做任何事情,只在退出时打印错误.它们不会干扰您的脚本.有一个解决方法,它被合并到GitHub上的master分支,但它还没有作为CasperJS的发布版本(最新的是1.1-beta3).
解决这个问题的最简单方法是降级到PhantomJS 1.9.7.由于您使用的是NPM,因此很容易完成
npm -g install phantomjs@1.9.7-15
Run Code Online (Sandbox Code Playgroud)
PhantomJS版本与NPM phantomjs软件包版本匹配,直到1.9.7,然后一切都中断.您可以查看版本npm show phantomjs.
如果降级到版本1.9.7,则必须使用--ssl-protocol=any命令行选项运行请求https资源的站点.我的答案在这里显示了原因.
解决这个问题的正确方法是从git安装新版本.这将使您不仅可以使用PhantomJS 1.9.8而无需额外的错误线,而且还可以使用CasperJS 1.1-beta3无法实现的PhantomJS 2.
参考文献:
GitHub问题#1068
CasperJS的解决方法#1139
SO上的PhantomJS问题