通过python获取Phantomjs的进程ID

时间:2014-03-24 06:19:44

标签: python phantomjs

我一直在运行python脚本以这种方式运行phatomjs命令:

cmd =“phantomjs --ignore-ssl-errors = yes rasterize.js输入输出”

status,output = commands.getstatusoutput(cmd)

状态和输出都很好。

我想得到phantomJS过程的PID。 有没有办法实现这个目标?

1 个答案:

答案 0 :(得分:1)

您可以在此处使用子流程模块:

import subprocess
cmd="phantomjs --ignore-ssl-errors=yes rasterize.js input output"
proc = subprocess.Popen([cmd])
print "PID of running process::", proc.pid