本文整理匯總了PHP中Goutte\Client::getInternalResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getInternalResponse方法的具體用法?PHP Client::getInternalResponse怎麽用?PHP Client::getInternalResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Goutte\Client
的用法示例。
在下文中一共展示了Client::getInternalResponse方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getItem
/**
* @param $item_url
* @param $i
* @return mixed
*/
public function getItem($itemUrl, $i)
{
$client = new Client();
//Go to the Sainsburys item page
$crawler = $client->request('GET', $itemUrl);
// Title
$title = $crawler->filter('#content > div.section.productContent > div.pdp > div > div.productTitleDescriptionContainer > h1')->text();
// Unit price
$price = $crawler->filter('div.priceTab > div.pricing > p.pricePerUnit')->text();
$priceFormatted = preg_replace("/([^0-9\\.])/i", "", $price);
// Size
$response = $client->getInternalResponse();
$size = $response->getHeader('Content-Length');
$sizeFormatted = $this->getFormattedSizeKB($size);
//convert from bytes to kilobytes
// Description
$description = $crawler->filter('#information > productcontent > htmlcontent > div.productText')->text();
// Results
$this->items['results'][] = ['title' => trim($title), 'size' => $sizeFormatted, 'unit_price' => $priceFormatted, 'description' => trim($description)];
return $this->items['results'][$i];
}
示例2: getResponseSize
/**
* Get's the content length of the latest request.
*
* @return string
*/
public function getResponseSize()
{
$response = $this->client->getInternalResponse();
return $response->getHeader('Content-Length');
}