jordan-thiriet/casperjsphp

CasperJS 的 PHP 封装

dev-master 2018-05-14 13:56 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:49:03 UTC


README

php-casperjs 是一个用于封装 CasperJs 的 PHP 库,便于编写功能测试。

安装

在使用 php-casperjs 之前,您需要安装以下库

1 - PhantomJS http://phantomjs.org/download.html

2 - CasperJS http://casperjs.org/installation.html

使用方法

<?php

$casper = new \CasperJS\Casper(1280,800,"script/test.js");
$casper->start("http://spallian.com/");
$casper->click('//*[@id="menu-item-7376"]/a');
$casper->forStart(1,21);
$casper->setValue('//*[@id="post-7148"]/div/div/div[{i}]/div/div[2]/h5','username');
$casper->getValue('username');
$casper->captureSelector('//*[@id="post-7148"]/div/div/div[{i}]/div/div[1]/img','capture/{username}.jpg');
$casper->forEnd();
$casper->run();
print_r($casper->getOutput());