示例#1
0
foreach ($html00->find('table[id="tbl-candidatos"]') as $candidatos) {
    $i = 0;
    foreach ($candidatos->find('tr') as $tbody) {
        if ($i > 2) {
            $pol[$i] = $tbody;
            $p = 0;
            foreach ($pol[$i]->find('td') as $parti) {
                if ($p == 4) {
                    $partido = $parti->plaintext;
                }
                $p++;
            }
            foreach ($pol[$i]->find('a') as $li) {
                if ($c >= $t) {
                    $link = "http://divulgacand2014.tse.jus.br" . $li->href;
                    //cada link corresponde a um politico
                    $resposta = rasPolitico($link, $partido);
                    //passado para a funcao o link da pagina do politico e a sigla do seu partido
                    $t++;
                    file_put_contents('/var/www/html/ligadopoliticos/controlador.txt', $t);
                }
                $c++;
            }
        }
        $i++;
    }
}
?>
</body>
</html>
         foreach ($dropdown->find('a') as $cat) {
             if ($k == 0) {
                 $categoria[$k] = "http://divulgacand2014.tse.jus.br" . $cat->href;
                 //$html00 = file_get_html($categoria[$k]);
                 $html00 = new simple_html_dom();
                 $html00->load_file($categoria[$k]);
                 foreach ($html00->find('table[id="tbl-candidatos"]') as $candidatos) {
                     $i = 0;
                     foreach ($candidatos->find('tr') as $tbody) {
                         if ($i > 2) {
                             $pol[$i] = $tbody;
                             foreach ($pol[$i]->find('a') as $li) {
                                 if ($c >= $t) {
                                     $link = "http://divulgacand2014.tse.jus.br" . $li->href;
                                     //echo $link."<br>";
                                     $resposta = rasPolitico($link);
                                     //echo $t."-";
                                     $t++;
                                     file_put_contents('/var/www/html/ligadopoliticos/controlador.txt', $t);
                                 }
                                 $c++;
                             }
                         }
                         $i++;
                     }
                 }
             }
             $k++;
         }
     }
 }