Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
creating conditional statements using curl and simplehtmldom

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>";
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda