I was using following code to scrap a web page it works normally on localhost but returns
require_once('advanced_html_dom.php');
$dom = file_get_html('http://exams.keralauniversity.ac.in/Login/index.php?reslt=1');
$rows = array();
foreach($dom->find('tr.Function_Text_Normal:has(td[3])') as $tr){
$row['num'] = $tr->find('td[2]', 0)->text;
$row['text'] = $tr->find('td[3]', 0)->text;
$row['pdf'] = $tr->find('td[3] a', 0)->href;
if(preg_match_all('/\d+/', $tr->parent->find('u', 0)->text, $m)){
list($row['day'], $row['month'], $row['year']) = $m[0];
}
// uncomment next 2 lines to save the pdf
// $filename = preg_replace('/.*\//', '', $row['pdf']);
// file_put_contents($filename, file_get_contents($row['pdf']));
$rows[] = $row;
}
var_dump($rows);
it shows following error when I inspected further
"Warning: Invalid argument supplied for foreach() in /home/a7944217/public_html/Results.php on line 477 "
var_dump this line $dom->find('tr.Function_Text_Normal:has(td[3])')
and $dom
returns null object when dumped shows this object(AdvancedHtmlDom)#1 (6) { ["xpath"]=> NULL ["root"]=> NULL ["doc"]=> RECURSION ["dom"]=> NULL ["node"]=> NULL ["is_text"]=> bool(false) }
file_get_html
returns null .whats causing this weird behaviour works fine in localhost but not in live server Page link