private function search($name)
 {
     try {
         $urlFetcher = new URLFetcher();
         $content = $urlFetcher->fetch('www.excelencias.org.br', '/@busca.php', array('nome' => $name));
         if (!preg_match('/Nenhum parlamentar encontrado/i', $content)) {
             $matches = array();
             if (preg_match('/\\<a class\\="listapar" href\\="([^"]+)"/', $content, $matches)) {
                 $url = parse_url($matches[1]);
                 $params = array();
                 $parts = explode('&amp;', $url['query']);
                 $parts[0] = explode('=', $parts[0]);
                 $parts[1] = explode('=', $parts[1]);
                 foreach ($parts as $part) {
                     $params[$part[0]] = $part[1];
                 }
                 $content = $urlFetcher->fetchXML('www.excelencias.org.br', $url['path'], $params);
                 $dom = new DOMDocument();
                 $dom->preserveWhiteSpace = false;
                 $dom->formatOutput = false;
                 $dom->loadHTML($content);
                 return $dom;
             }
         }
     } catch (\Exception $e) {
     }
 }
 private function getPageContents($page)
 {
     $fetcher = new URLFetcher();
     return $fetcher->fetch('www.eleicoes2012.info', $this->path . '/alf/' . $page . '/');
 }
Ejemplo n.º 3
0
 private function getPageContents($path)
 {
     $fetcher = new URLFetcher();
     return $fetcher->fetch('www.eleicoes2012.info', $path);
 }