新手问题 phantomjs 在 rails 里面使用问题?

yldcb · December 25, 2014 · Last by saiga replied at December 25, 2014 · 2179 hits

想做截图功能 因为找了很久没找到相关例子,虽然引用了 phantomjs gem 但是不知道怎么使用。 后来想了个傻办法,shell 执行命令 在 main controller 我是这么写的: require 'pathname' class MainController < ApplicationController def index path = Pathname.new(File.dirname(FILE)).realpath + "../../public" url = "http://www.baidu.com" img = "hello.png" exec = "#{path}" + "/phantomjs #{path}/exec.js #{url} #{img}" system "#{exec}" puts "ok"

end end 但是不执行。不知道什么原因 希望用过 phantomjs 的能够指点一下,非常感激

我用的是这个 gem : https://github.com/vitalie/webshot 不过它用的 js 引擎 Poltergeist 有点问题,有些超时请求会导致整个 webshot 实例错误。

广告:我的网站就是用这个 http://web-colle.herokuapp.com/

You need to Sign in before reply, if you don't have an account, please Sign up first.