- 文件系统模块
 - PhantomJS - 属性
 - PhantomJS - 方法
 
- 系统模块
 - PhantomJS - 属性
 
- 网络服务器模块
 - PhantomJS - 属性
 - PhantomJS - 方法
 
- 各种各样的
 - 命令行界面
 - PhantomJS - 屏幕截图
 - PhantomJS - 页面自动化
 - PhantomJS - 网络监控
 - PhantomJS - 测试
 - PhantomJS-REPL
 - PhantomJS - 示例
 
- PhantomJS 有用资源
 - PhantomJS - 快速指南
 - PhantomJS - 有用的资源
 - PhantomJS - 讨论
 
网页子进程模块
Phantomjs 子进程模块有助于与子进程交互并使用stdin /stdout/stderr与它们对话。子进程可用于打印、发送邮件或调用用另一种语言编写的程序等任务。要创建子进程模块,您需要引用。
例如 -
var process = require("child_process");
生成方法
通过spawn子进程,您可以订阅其stdout和stderr流以实时获取数据。
句法
其语法如下 -
var spawn = require('child_process').spawn;
例子
让我们看一个spawn方法的例子。
var process = require("child_process")
var spawn = process.spawn
var child = spawn("cmd", ['/c', 'dir']);
child.stdout.on("data", function (data) {
   console.log("spawnSTDOUT---VALUE:", JSON.stringify(data))
})
child.stderr.on("data", function (data) {
   console.log("spawnSTDERR:", JSON.stringify(data))
})
child.on("exit", function (code) {
   console.log("spawnEXIT:", code)
})
输出
上述程序生成以下输出。
spawnSTDOUT---VALUE: " Volume in drive C is OS\r\n" spawnSTDOUT---VALUE: " Volume Serial Number is 7682-9C1B\r\n\r\n Directory of C: \\phantomjs\\bin\r\n\r\n" spawnSTDOUT---VALUE: "20-05-2017 10:01 <DIR> .\r\n20-05-2017 10:01 <DIR> ..\r\n13-05-2017 20:48 12 a,txt.txt\r\n07-05-2017 08:51 63 a.js\r\n06-05-2017 16:32 120,232 a.pdf\r\n13-05-2017 20:49 spawnEXIT: 0