我想在本地主机上执行PHP中的PhantomJS。
谁能解释一下如何在PHP中执行PhantomJS,以及我应该从phantomjs.org下载什么包?
发布于 2016-06-12 01:56:13
我最近发布了一个项目,允许PHP访问浏览器。在这里获取:https://github.com/merlinthemagic/MTS。在幕后,它依赖于PhantomJS。
下载并设置后,您只需使用以下代码:
$myUrl = "http://www.example.com";
$windowObj = \MTS\Factories::getDevices()->getLocalHost()->getBrowser('phantomjs')->getNewWindow($myUrl);
//now you can either retrive the DOM and parse it, like this:
$domData = $windowObj->getDom();
//or take screen shots
$imageData = $windowObj->screenshot();
//or use the mouse to click buttons:
$windowObj->mouseEventOnElement("[id=searchInput]", 'leftclick');
//or type with the keyboard :
$windowObj->sendKeyPresses("my search words");
//or load and execute custom javascript, fill forms etc, etc.
https://stackoverflow.com/questions/20202407
复制相似问题