本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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]];
}
示例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;
}