Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.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
Javascript Meteor PhantomJS动态URL参数_Javascript_Node.js_Meteor_Phantomjs - Fatal编程技术网

Javascript Meteor PhantomJS动态URL参数

Javascript Meteor PhantomJS动态URL参数,javascript,node.js,meteor,phantomjs,Javascript,Node.js,Meteor,Phantomjs,我已经在我的Meteor应用程序中安装了PhantomJS,使用下面答案中的说明: 但所涉及的方法是: (private/phantomDriver.js) 有一个设置的URL。。。如何向文件传递参数以更改URL?e、 g page.open(URL, etc...) 这: 日志 控制台的“stdout:ReferenceError:找不到变量:URL” Artjom B.的链接没有解决这个问题(需要使用spawn(phantomjs.path)而exec需要一个我不知道的字符串),尽管它确实

我已经在我的Meteor应用程序中安装了PhantomJS,使用下面答案中的说明: 但所涉及的方法是:

(private/phantomDriver.js)

有一个设置的URL。。。如何向文件传递参数以更改URL?e、 g

page.open(URL, etc...)
这:

日志

控制台的“stdout:ReferenceError:找不到变量:URL”


Artjom B.的链接没有解决这个问题(需要使用
spawn(phantomjs.path)
exec
需要一个我不知道的字符串),尽管它确实让我找到了答案,谢谢

还使用了
require('system').args
访问通过
spawn发送的参数

最终代码:

server.js:

spawn(phantomjs.path, ['assets/app/phantom_driver.js',URL]);
private/phantomDriver.js

var page = require('webpage').create();
page.open('http://github.com/', function (){
  console.log('Page Loaded');
  page.render('github.png');
  phantom.exit();
});
var page = require('webpage').create();
var args = require('system').args;
var URL = args[1]

page.open(URL, function(status) {
  console.log('Page loaded. Status: ' + status);
  page.render('github.png');
  phantom.exit();
})
问题可能不匹配,但答案可能匹配。
var page = require('webpage').create();
var args = require('system').args;
var URL = args[1]

page.open(URL, function(status) {
  console.log('Page loaded. Status: ' + status);
  page.render('github.png');
  phantom.exit();
})