是否可以从node.js作为命令行参数运行PhantomJS [英] Is it possible to run PhantomJS from node.js as a command line argument

查看:87
本文介绍了是否可以从node.js作为命令行参数运行PhantomJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近打算测试从python作为命令行参数运行phantomJS,我还不了解它,但已经看到了示例.因为PhantomJS是从命令行运行的,所以这似乎是可行的. PhantomJS吐出的结果将直接进入变量.

I was recently going to test out running phantomJS from python as a commandline argument, I haven't got round to it yet but have seen examples. Because PhantomJS is run from the command line this seems to be possible. The result that PhantomJS would spit out would go straight into a variable.

在我走这条路之前,在node.js中进行这项工作实际上对我来说更有用,这让我开始思考,当程序从命令行运行时,我是否可以仅使用node来运行PhantomJS并存储PhantomJS通常会吐出一个变量的数据结果?

Before I go down that path, making this work in node.js would actually be more useful for me and it got me thinking, can i just use to node to run PhantomJS as a program gets run from the commandline and store the data result that PhantomJS would normally spit out into a variable?

我宁愿不使用 phantomjs-node ,因为它似乎使用了很多技巧.

I would rather not use phantomjs-node because it seems to be using too many tricks.

所有这些的原因是能够与程序执行的另一操作同时运行PhantomJS并将其记录的结果数据用于其他用途.

The reason for all of this is to be able to run PhantomJS at the same time as another action the program takes and use the resulting data its recorded for some other stuff.

简单地说,您可以在python中运行系统命令行内容,我可以在node.js中执行相同的操作吗?

Simply put, you can run system command line stuff in python, can I do the same in node.js?

干杯:)

我知道node和phantom使用不同的js环境,这很酷,因为我只想将phantom作为其自己的进程运行并将所有输出数据捕获到node.js变量中(数据将是一个对,字符串和浮点数.)我不想用幻像来驱动",我将制作已加载的javascript文件以执行我想要的操作.我想要的只是幻像输出. :)

I understand that node and phantom use different js environments, that's cool because I just want to run phantom as its own process and catch all that output data into a node.js variable (the data will be a array of a pair, string and floating point.) I don't want to 'drive' with phantom, I will craft the loaded javascript files todo what I want. All I want is phantom output. :)

推荐答案

我想您可以为Node.js运行一个简单的脚本.在该脚本中,phantomjs脚本将作为子进程运行.您可以在此答案中看到工作的示例(以及一些文档的链接).我想此讨论可能对您有所帮助你也是.

I suppose you can make a simple script for Node.js to run; in that script phantomjs script will be run as a child process. You can see the working example (and links for some documentation) in this answer. I suppose this discussion might be helpful for you as well.

这篇关于是否可以从node.js作为命令行参数运行PhantomJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆