Im building a simple web scraper that goes to some urls and get some information, but case in the page containains specific text content, i wish to get out the current loop and continue to the next, the only strange beaviour is that i can output the label that i use to create the conditional, but it doesnt work, is like that doesnt exist.
My code:
for($i = 0; $i< 5; $i++){
curl_setopt($ch, CURLOPT_URL, 'url/details.php?med_id='.$i);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
$answer = curl_exec($ch);
//echo $answer;
if (curl_error($ch)) {
echo curl_error($ch);
}
$html = str_get_html($answer);
$table = $html->find('table', 3);
/*
*$table->find('td',17)->plaintext => could be "Comercializado" or "Não comercializado", so if is "Não comercializado" it goes to the next iteration.
I already output the text "$table->find('td',17)->plaintext" to see if appeaars and looks ok.
*/
if (strpos($table->find('td',17)->plaintext, 'Não comercializado') !== false) {
continue;
}
echo "<tr>";
echo "<td>".$table->find('td',17)."</td>";
echo "<td>".$table->find('td',14)."</td>";
echo " <td>".$table->find('td',22)."</td>";
echo "<td>".$table->find('td',25)."</td>";
echo "</tr>";
}
echo "</table>";