foreach中的条件检查导致错误

时间:2016-08-13 05:50:54

标签: php screen-scraping simple-html-dom

我正在使用Simple_html_dom尝试抓取Reputation points并检查这些值,然后仅提取Repu大于200的用户个人资料。下面是代码,这样做时工作正常

`

$html2=str_get_html($html1);
foreach ($html2->find('.user-details') as $value) {

        foreach($html2->find('.reputation-score') as $repu){


                echo (int)$repu->plaintext.$value.'<br>';

        }
        }

When doing the above i am getting all the信誉和用户详细信息well each line, looks fine till now. But now i wanna perform a条件检查and then echo only those profiles whose repo is higher than 100`。所以当我尝试下面的代码时

`

$html2=str_get_html($html1);

foreach ($html2->find('.user-details') as $value) {

        foreach($html2->find('.reputation-score') as $repu){

                if($repu>100)
                {
                echo ($repu->plaintext.$value.'<br>';
            }
        }
        }

我收到一条错误,说类simple_html_dom_node的对象无法转换为int ,因为我已尝试执行(int)转换,然后echo仍然无法解决

这里有任何帮助吗?

0 个答案:

没有答案