I m trying to parse a post related statement from a forum site using PHP dom parser. It works when we insert individual url's of the page, but when we try to apply a while loop logic it kinda prints only one page multiple times..
my code as goes::
<?php
set_time_limit(3600);
$i = 1;
$e = 839304-$i;
while(true){
require_once('dom/simple_html_dom.php');
$html =file_get_html('http://www.usmleforum.com/files/forum/2017/1/'.$e.'.php');
foreach ($html->find("tr") as $row) {
$element = $row->find('td.Text2',0);
if ($element == null) { continue; }
$textNode = array_filter($element->nodes, function ($n) {
return $n->nodetype == 3; //Text node type, like in jQuery
});
if (!empty($textNode)) {
$text = current($textNode);
echo $text."<br>";
}
}
$i++;
}
?>
as the result indicates, it only prints the statement from page 839303, but it prints it multiple times and still loads on.. so its clear that this code is skipping the $i++ line somehow and runs again...
Any help is appreciated...