本文整理汇总了PHP中Symfony\Component\DomCrawler\Crawler::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Crawler::current方法的具体用法?PHP Crawler::current怎么用?PHP Crawler::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DomCrawler\Crawler
的用法示例。
在下文中一共展示了Crawler::current方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: walkProperties
/**
* Iterates over all properties of current item
*/
public function walkProperties($callback)
{
$crawler = new Crawler($this->crawler->current());
return $crawler->filter('item property')->each(function ($e) use($callback) {
$sxml = simplexml_import_dom($e);
$callback(current($sxml->attributes()) + array('@value' => (string) $sxml));
});
}
示例3: 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();
}
示例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');
}
示例5: current
/**
* (PHP 5 >= 5.0.0)<br/>
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
*/
public function current()
{
$node = $this->crawler->current();
$data = $this->extractor->extract($node);
return $data;
}