当前位置: 首页>>代码示例>>PHP>>正文


PHP Crawler::rewind方法代码示例

本文整理汇总了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');
 }
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:24,代码来源:BrowserKitDriver.php

示例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();
 }
开发者ID:tolik505,项目名称:yii2-related-form,代码行数:23,代码来源:RelatedFormWidget.php

示例3: rewind

 /**
  * Iterator interface implementation
  *
  * @group Iterator
  */
 function rewind()
 {
     $this->crawler->rewind();
 }
开发者ID:aakb,项目名称:bpi-client,代码行数:9,代码来源:Document.php

示例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');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:18,代码来源:BrowserKitDriver.php


注:本文中的Symfony\Component\DomCrawler\Crawler::rewind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。