Esempio n. 1
0
 public static function get_ids($region)
 {
     $url = "http://avibase.bsc-eoc.org/checklist.jsp?region=" . $region . "&list=clements";
     $ch = curl_init();
     $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.79 Safari/537.1';
     // simule Firefox 4.
     $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
     $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
     $header[] = "Cache-Control: max-age=0";
     $header[] = "Connection: keep-alive";
     $header[] = "Keep-Alive: 300";
     $header[] = "Accept-Charset: utf-8";
     $header[] = "Accept-Language: en";
     // langue fr.
     $header[] = "Pragma: ";
     // Simule un navigateur
     //curl_setopt($ch, CURLOPT_PROXY, 'proxy.int.world.socgen:8080');
     //curl_setopt($ch, CURLOPT_PROXYUSERPWD, "aurelien.lequoy:xxxxx");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
     $content = curl_exec($ch);
     curl_close($ch);
     $data = array();
     $content2 = \Grabber::getTagContent($content, '<table class="AVBlist">', true);
     $content2 = str_replace('<a href="species.jsp?avibaseid=', '.', $content2);
     $content2 = str_replace('"><i>', '.', $content2);
     $content2 = str_replace('&nbsp;', '', $content2);
     $content2 = strip_tags($content2);
     $content2 = explode('.', $content2);
     $i = 0;
     while (isset($content2[$i])) {
         if (!preg_match('#[0-9]#', $content2[$i])) {
             unset($content2[$i]);
         }
         $i++;
     }
     $data = $content2;
     return $data;
 }