问题描述
我想知道是否可以在服务器端运行浏览器(特别是浏览器引擎)。我不只是想渲染一个页面,而是让浏览器打开一段时间,运行一些JS,点击一下或按一些键,同时抓住图形输出。
PhantomJS做你所描述的。它基本上是一个无头浏览器 -
您可以通过任何服务器端语言运行服务器端。请参阅下面的NodeJS和PHP的一些集成模块
NodeJS
PHP
I was wondering if it is possible to run a browser (specifically a browser engine) on the server side. I do not just mean to render a page but to keep a browser open for some time, run some JS, do some clicks or press some keys and meanwhile grab the graphical output.
Does anyone know how to accomplish this? So far my only idea was to run the browser in a VNC, RDP etc. session but this seems like an overkill to me.
PhantomJS does what you are describing. It is basically a headless browser - http://phantomjs.org/
you can run it server side via any server side language. See some integration modules below for NodeJS and PHP
NodeJS
https://npmjs.org/package/node-phantom
https://github.com/sgentle/phantomjs-node
PHP
https://github.com/diggin/php-PhantomjsRunner
这篇关于服务器端浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!