如何从PHP执行PhantomJS [英] how to Execute PhantomJS from PHP

查看:848
本文介绍了如何从PHP执行PhantomJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在localhost上从PHP执行PhantomJS。

I want to execute PhantomJS from PHP on localhost.

任何机构都可以解释如何从PHP执行PhantomJS以及我应该从phantomjs.org下载什么软件包?

Can any body explain how to execute PhantomJS from PHP and what package I should download from phantomjs.org?

推荐答案


  • 下载 PhantomJS二进制,将其上传到某处并使其可执行( chmod + x

  • if你要制作截图,设置 fontconfig (这是我的配置非常具体,但目标是确保系统上至少有一些字体)

  • 在PHP中运行以下命令:

    $ response = exec('/ path / to / phantomjs myscript.js');

    • download the PhantomJS binary, upload it somewhere and make it executable (chmod +x)
    • if you are going to make screenshots, setup fontconfig (this is pretty specific to my config but the goal is to make sure to have at least some fonts on your system)
    • run the following in PHP:
      $response = exec('/path/to/phantomjs myscript.js');
    • 这篇关于如何从PHP执行PhantomJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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