Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: multi_curl
Форумы портала PHP.SU » » Работа с сетью » multi_curl

Страниц (1): [1]
 

1. fagot - 16 Марта, 2014 - 20:30:47 - перейти к сообщению
Помогите переписать под multi_curl такой код

PHP:
скопировать код в буфер обмена
  1.  
  2. <?PHP
  3.  
  4.  
  5.  
  6. function naim(){
  7.   function naime ($cook){  
  8.    $urll = 'http://mgero.mobi/game/battle/mercenary/new?type=crystal';  
  9.    $url = 'http://mgero.mobi/game';      
  10.   $ch = curl_init();
  11.    curl_setopt($ch, CURLOPT_URL, $urll)  ;        
  12.    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
  13.    curl_setopt($ch, CURLOPT_COOKIEFILE, "{$cook}.txt");        
  14.    $html = curl_exec($ch);  
  15.    curl_close($ch);        
  16.     //echo $html;
  17.  
  18.         if (preg_match('!<a[^>]+href="/game/battle/mercenary/engage?([^ >]+)[^>]*>(.*?)</a>!',$html,$ok))  
  19.     $na= $ok[1];
  20.         $na=str_replace('"','',$na);
  21.         return $na;;
  22.         }
  23.  
  24. function go ($na, $cook){  
  25.    $urll = "http://mgero.mobi/game/battle/mercenary/engage{$na}";  
  26.   $ch = curl_init();
  27.    curl_setopt($ch, CURLOPT_URL, $urll)  ;        
  28.    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
  29.    curl_setopt($ch, CURLOPT_COOKIEFILE, "{$cook}.txt");      
  30.    $html = curl_exec($ch);  
  31.    curl_close($ch);        
  32.    //echo $html;
  33.  
  34.    }
  35.    
  36.    
  37. $cooks = array(
  38.     'king',
  39.     'ger',
  40. );
  41.  
  42. foreach ($cooks as $cook ) {
  43.    go(naime($cook), $cook);
  44.    }
  45. }


а то самому не получаетса Огорчение

 

Powered by ExBB FM 1.0 RC1