當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crawler::current方法代碼示例

本文整理匯總了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');
 }
開發者ID:penguinclub,項目名稱:penguinweb_drupal8,代碼行數:24,代碼來源:BrowserKitDriver.php

示例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));
     });
 }
開發者ID:aakb,項目名稱:bpi-client,代碼行數:11,代碼來源:Document.php

示例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();
 }
開發者ID:tolik505,項目名稱:yii2-related-form,代碼行數:23,代碼來源:RelatedFormWidget.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

示例5: current

 /**
  * (PHP 5 &gt;= 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;
 }
開發者ID:yevgen-grytsay,項目名稱:etl-suite,代碼行數:12,代碼來源:XmlIterator.php


注:本文中的Symfony\Component\DomCrawler\Crawler::current方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。