本文整理汇总了PHP中Symfony\Component\DomCrawler\Crawler::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP Crawler::rewind方法的具体用法?PHP Crawler::rewind怎么用?PHP Crawler::rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DomCrawler\Crawler
的用法示例。
在下文中一共展示了Crawler::rewind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCrawlerNode
/**
* Returns DOMElement from crawler instance.
*
* @param Crawler $crawler
*
* @return \DOMElement
*
* @throws DriverException when the node does not exist
*/
private function getCrawlerNode(Crawler $crawler)
{
$node = null;
if ($crawler instanceof \Iterator) {
// for symfony 2.3 compatibility as getNode is not public before symfony 2.4
$crawler->rewind();
$node = $crawler->current();
} else {
$node = $crawler->getNode(0);
}
if (null !== $node) {
return $node;
}
throw new DriverException('The element does not exist');
}
示例2: removeLastItem
/**
* @param $content string
*
* @return string
*/
private function removeLastItem($content)
{
$document = new \DOMDocument('1.0', \Yii::$app->charset);
$crawler = new Crawler();
$crawler->addHTMLContent($content, \Yii::$app->charset);
$root = $document->appendChild($document->createElement('_root'));
$crawler->rewind();
$root->appendChild($document->importNode($crawler->current(), true));
$domxpath = new \DOMXPath($document);
$crawlerInverse = $domxpath->query(CssSelector::toXPath($this->widgetItem . ':last-child'));
foreach ($crawlerInverse as $key => $elementToRemove) {
$parent = $elementToRemove->parentNode;
$parent->removeChild($elementToRemove);
}
$crawler->clear();
$crawler->add($document);
return $crawler->filter('body')->eq(0)->html();
}
示例3: rewind
/**
* Iterator interface implementation
*
* @group Iterator
*/
function rewind()
{
$this->crawler->rewind();
}
示例4: getCrawlerNode
/**
* Returns DOMElement from crawler instance.
*
* @param Crawler $crawler
*
* @return \DOMElement
*
* @throws DriverException when the node does not exist
*/
private function getCrawlerNode(Crawler $crawler)
{
$crawler->rewind();
$node = $crawler->current();
if (null !== $node) {
return $node;
}
throw new DriverException('The element does not exist');
}