Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda