首先,我使用节点phantomJS bridge。需要指定一个配置文件到PhantomJS节点桥
PhantomJS是v1.9.2的
节点是v0.10.15
我的问题是,我不能设置一个配置文件来phantomJS节点。
基本上我的代码有云:
在console.log(settings);
var phantom = require("node-phantom");
phantom.create(function (err, ph){
ph.createPage(function (err, page){
page.set("settings.config", "./myConfig.json");
page.get("settings", function(err, settings){
console.log(settings);
});
});
});
我只获得默认设置:
{ XSSAuditingEnabled: false,
javascriptCanCloseWindows: true,
javascriptCanOpenWindows: true,
javascriptEnabled: true,
loadImages: true,
localToRemoteUrlAccessEnabled: false,
userAgent: 'Mozilla/5.0 (Macintosh; PPC Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.2 Safari/534.34',
webSecurityEnabled: true }
我试过很多东西分配我的配置的文件phantomJS或我的网页实例,没有运气。
set('settings.config')
on phantom
or phant
,但没有任何结果。
我也试过,因为它在Doc的说:
phantom.create("--config=./path/to/config.json", function (err, ph){
...
});
错误,需要一个函数作为第一个参数。所以我试过了:
phantom.create(function (err, ph){
...
}, {"--config":"./path/to/config.json"});
还是没有运气。
我错过了什么吗?
谢谢你的时间。
编辑:我没有使用正确的文档(-_-)...
因此,与node-phantom
(我终于用一个),这样做的正确方法是:
phantom.create(callback, { parameters : {"config" : "path/to/file.json" }});
我可以证实,它现在正在工作。
OMG!我是个白痴...... 'node-phantom'的等价物是: 'phantom.create(callback,{parameters:{“config”:“path/to/file.json”}}); ' 我可以证实,它现在正在工作。 – YoannM