尝试在PHP中使用简单的html dom解析器从span获取内容

尝试在PHP中使用简单的html dom解析器从span获取内容,php,html,Php,Html,我正试图从这个跨度中获取内容 <span class="contact-seller-name ng-binding">martin</span> 但问题是我总是犯这样的错误: 注意:尝试在中获取非对象的属性 第30行的E:\Programs\xampp\htdocs\personal\php dom\WebScraping\test3.php 尝试将$value用作数组: <?php // finding against the m

我正试图从这个跨度中获取内容

<span class="contact-seller-name ng-binding">martin</span>
但问题是我总是犯这样的错误:

注意:尝试在中获取非对象的属性 第30行的E:\Programs\xampp\htdocs\personal\php dom\WebScraping\test3.php


尝试将
$value
用作数组:

<?php 
    // finding against the multiple
    // 0 is for the first span element
    $value = $html->find('span#ur_span_id');
    foreach($value  as $p) {
        $span_test =  $p->outertext; 
    }
    //can use class too in find section
?>


第30行是哪一行?echo$value->innertext;尝试查找(“span[class=contact seller name]”@AlexeyShatrov仍然收到相同的错误。我在书面url中看不到任何
span
。请为您的答案添加一些解释,以便其他人可以从中学习。正如我看到的,您使用的是完全不同的选择器,例如//查找id=foo$ret=$html的所有元素->查找(“#foo”);//查找class=foo$ret=$html->Find('.foo');//查找所有具有属性id$ret=$html->Find('*[id]')的元素;//查找所有锚和图像$ret=$html->Find('a,img');//查找具有“title”属性$ret=$html->Find('a[title],img[title')的所有锚和图像);如需了解更多详细信息,请在回答中添加所有解释
<?php 
    // finding against the multiple
    // 0 is for the first span element
    $value = $html->find('span#ur_span_id');
    foreach($value  as $p) {
        $span_test =  $p->outertext; 
    }
    //can use class too in find section
?>