从Ruby on Rails应用程序运行phantomjs [英] Running phantomjs from a Ruby on Rails application

查看:201
本文介绍了从Ruby on Rails应用程序运行phantomjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣使用 Phantomjs ,而且我想从我的Ruby on Rails应用程式执行。但是,这是一个命令行工具(即我需要运行 phantomjs rasterize.js http: //raphaeljs.com/polar-clock.html clock.png 在我的终端)。

I'm interested in using Phantomjs and I'd like to run it from my Ruby on Rails application. However, this is a command line tool (i.e. I'd need to run something like phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png in my terminal). How would I execute a command line tool from my app?

推荐答案

在你的ruby代码中使用反引号,例如:

Use backticks in your ruby code e.g.:

output = `phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png`

这篇关于从Ruby on Rails应用程序运行phantomjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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