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


PHP Crawler::nodeName方法代码示例

本文整理汇总了PHP中Symfony\Component\DomCrawler\Crawler::nodeName方法的典型用法代码示例。如果您正苦于以下问题:PHP Crawler::nodeName方法的具体用法?PHP Crawler::nodeName怎么用?PHP Crawler::nodeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DomCrawler\Crawler的用法示例。


在下文中一共展示了Crawler::nodeName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: looksLikeGroupTitle

 protected function looksLikeGroupTitle(Crawler $node)
 {
     $tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'strong', 'dt'];
     if (in_array($node->nodeName(), $tags)) {
         return true;
     }
     if (preg_match('/[#\\*\\-_=\\+]{2,}/', $node->text())) {
         return true;
     }
     if (':' === substr($node->text(), -1)) {
         return true;
     }
     if (false !== strpos($node->attr('class'), 'header')) {
         return true;
     }
     if (false !== strpos($node->attr('class'), 'title')) {
         return true;
     }
     return false;
 }
开发者ID:ssnepenthe,项目名称:recipe-scraper,代码行数:20,代码来源:Base.php

示例2: getCheckedValueFromRadioGroup

 /**
  * Get the checked value from a radio group.
  *
  * @param  \Symfony\Component\DomCrawler\Crawler  $radioGroup
  * @return string|null
  *
  * @throws \Exception
  */
 protected function getCheckedValueFromRadioGroup(Crawler $radioGroup)
 {
     if ($radioGroup->nodeName() !== 'input' || $radioGroup->attr('type') !== 'radio') {
         throw new Exception('Given element is not a radio button.');
     }
     foreach ($radioGroup as $radio) {
         if ($radio->hasAttribute('checked')) {
             return $radio->getAttribute('value');
         }
     }
     return;
 }
开发者ID:hanifn,项目名称:laravel-framework,代码行数:20,代码来源:InteractsWithPages.php

示例3: process_General

 /**
  * Process general node.
  *
  * @since  0.9.0
  *
  * @param \Symfony\Component\DomCrawler\Crawler $node
  *
  * @return \stdClass
  *
  * @author nguyenvanduocit
  */
 public function process_General(Crawler &$node)
 {
     $newNode = new \stdClass();
     $newNode->nodeName = $node->nodeName();
     $newNode->text = $node->text();
     return $newNode;
 }
开发者ID:nguyenvanduocit,项目名称:WP-Translatable-Cloner,代码行数:18,代码来源:PostCloner.php

示例4: getSimilarSiblingsInfo

 /**
  * @param Crawler $block
  * @return array
  */
 public function getSimilarSiblingsInfo(Crawler $block)
 {
     $all_siblings = $block->parents()->first()->children();
     $siblings = [$block];
     $sample_node = $block->getNode(0);
     $sample_tag = $block->nodeName();
     $sample_classes = explode(' ', $block->extract(['class'])[0]);
     foreach ($all_siblings as $sibling) {
         if ($sample_node->isSameNode($sibling)) {
             continue;
         }
         $to_add = false;
         if ($sibling->nodeName == $sample_tag) {
             if ($sample_classes === FALSE) {
                 $to_add = true;
             } else {
                 $sibling_classes = explode(' ', $sibling->getAttribute('class'));
                 $matched_classes = array_intersect($sample_classes, $sibling_classes);
                 if (!empty($matched_classes)) {
                     if ($matched_classes != $sample_classes) {
                         $sample_classes = $matched_classes;
                     }
                     $to_add = true;
                 }
             }
         }
         if ($to_add) {
             $siblings[] = new Crawler($sibling);
         }
     }
     return [$siblings, ['tag' => $sample_tag, 'classes' => $sample_classes]];
 }
开发者ID:nfqakademija,项目名称:dydis-turi-reiksme,代码行数:36,代码来源:ClassMatcher.php

示例5: lookupStructure

 /**
  * @param Crawler $blocks
  * @return array
  */
 public function lookupStructure(Crawler $blocks)
 {
     $structure = array();
     foreach ($blocks as $block) {
         $block = new Crawler($block);
         $children = $block->children();
         $children_structure = null;
         if ($children->getNode(0) != null) {
             $children_structure = $this->lookupStructure($children);
         }
         $structure[] = ['tag' => $block->nodeName(), 'children' => $children_structure];
     }
     return $structure;
 }
开发者ID:nfqakademija,项目名称:dydis-turi-reiksme,代码行数:18,代码来源:Validationer.php


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