本文整理匯總了PHP中WebGuy::grabMultiple方法的典型用法代碼示例。如果您正苦於以下問題:PHP WebGuy::grabMultiple方法的具體用法?PHP WebGuy::grabMultiple怎麽用?PHP WebGuy::grabMultiple使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WebGuy
的用法示例。
在下文中一共展示了WebGuy::grabMultiple方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: WebGuy
<?php
/**
* @file
* Crawl each of the URLs on the front page, checking that each is returning a 200 (OK).
*/
$I = new WebGuy($scenario);
$I->wantTo('crawl the front page for links and check that each link is returning a 200 (OK) status');
// Navigate to the front page.
$I->amOnPage('/');
// Check the repsonse code for the front page is 200 (OK).
$I->seeResponseCodeIs(200);
// Grab all a[href] values.
$elements = $I->grabMultiple('a', 'href');
// Loop through the links array and check the status code of each one.
foreach ($elements as $element) {
// Split the URL up into different parts.
$el = parse_url($element);
// Make sure the host and path is set.
if (isset($el['host']) && isset($el['path'])) {
// Check each path returns a 200 (OK) status.
if ($el['host'] == $GLOBALS['host']) {
// Navigate to the
$I->amOnPage($el['path']);
$I->seeResponseCodeIs(200);
}
}
}