Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 简单的HTML DOM解析器;返回0个问题_Php_Html Parsing_Simple Html Dom - Fatal编程技术网

Php 简单的HTML DOM解析器;返回0个问题

Php 简单的HTML DOM解析器;返回0个问题,php,html-parsing,simple-html-dom,Php,Html Parsing,Simple Html Dom,我正在使用以下代码: $url = 'http://www.publicwhip.org.uk/mp.php?mpn=' . $avariable . '&mpc=' . $anothervariable . '&house=commons&display=everyvote#divisions'; $options = array('http' => array('header' => "User-Agent: Mozilla/5.0 (Windows; U

我正在使用以下代码:

$url = 'http://www.publicwhip.org.uk/mp.php?mpn=' . $avariable . '&mpc=' . $anothervariable . '&house=commons&display=everyvote#divisions';
$options = array('http' => array('header' => "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.125 Safari/533.4"));
$context = stream_context_create($options);
$html = file_get_html($url, false, $context);

foreach($html->find('table.votes tr.odd,tr.even') as $tr) {
  if ($tr->find('td', 3) == '<td>absent</td>') { $voted = $voted + 1; }
  $possible = $possible + 1;
}

但是当我到达

http://www.publicwhip.org.uk/mp.php?mpn=Jim_Dowd&mpc=Lewisham_West_and_Penge&house=commons&display=everyvote#divisions

当有几个值需要计数时,它给我0

我查看了每个页面的布局,它们都是相同的,所以我不明白为什么在某些页面上返回0

编辑:

当我取下支票时

if($html && is_object($html) && isset($html->nodes))
它回来了

Fatal error: Call to a member function find() 
我不理解这一点,因为我上面提到的所有4页都有类似的结构

http://www.publicwhip.org.uk/mp.php?mpn=Tom_Watson&mpc=West_Bromwich_East&house=commons&display=everyvote#divisions
if($html && is_object($html) && isset($html->nodes))
Fatal error: Call to a member function find()