本文整理汇总了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');
}