forked from TobiaszCudnik/phpquery
-
Notifications
You must be signed in to change notification settings - Fork 66
WebBrowser
didier Belot edited this page Mar 6, 2018
·
1 revision
WebBrowser is a phpQuery plugin that mimics behaviors of web browser. Thanks to that developer can simulate user's behavior inside a PHP script.
- Link navigation (click event)
- Form navigation (submit event)
- Cookies (thought Zend_Http_CookieJar)
- Relative links
- document.location (not an object, yet)
- Fill forms and submit them easly
- Login to secure pages and collect content
- Write test cases reproducing browsing proccess
Adding web browser functionality to existing phpQuery object and submiting the form.
->WebBrowser('callback')->find('form')->submit()->...
Querying Google against "search phrase":
require_once('phpQuery/phpQuery.php');
phpQuery::browserGet('http://www.google.com/', 'success1');
function success1($browser) {
$browser
->WebBrowser('success2')
->find('input[name=q]')
->val('search phrase')
->parents('form')
->submit();
}
function success2($browser) {
print $browser;
}