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 :: Версия для печати :: Неправильно работает цикл [2]
Форумы портала PHP.SU » » Вопросы новичков » Неправильно работает цикл

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

16. Microteam - 05 Декабря, 2011 - 12:29:12 - перейти к сообщению

А если у меня модем настроен как MER (Mac Encapsulating Routing)... и вместо логина с паролем у меня DNS(((

Извиняюсь за свой выше пост, я не туда написал... А?!

PHP:
скопировать код в буфер обмена
  1.  
  2. for ($r=0; $r<$count_pre; $r++){
  3.  
  4.     $url = 'http://tradein.arteks.ru'.substr($links_pre[0][$r],8,-2);
  5.     ####################################
  6.    $contents = file_get_contents($url); #ВОТ ЗДЕСЬ       #
  7.    ####################################
  8.    $tag_in = '<div class="text_foto" id="foto">';
  9.     $tag_out = '<div class="text_only" id="txt" style="display:none;">';
  10.  
  11.     $position = strpos($contents,$tag_in);
  12.     $contents = substr($contents,$position);
  13.  
  14.     $position = strpos($contents,$tag_out);
  15.     $contents = substr($contents,0,$position);
  16.  
  17.     preg_match_all('/class="car_zag"[^>]+>/',$contents,$links);
  18.  
  19.     $tag_in = '<div style="width:180px;float:left;padding-left:10px;margin-top:10px;height:370px;overflow-y: scroll;">';
  20.     $tag_out = '<div style="clear:both">';
  21.  
  22.     $count = count($links[0]);
  23.     for ($i=0; $i<$count; $i++){
  24. #########################################################
  25.        $contents = file_get_contents('http://tradein.arteks.ru'.substr($links[0][$i],22,-2)); #ВОТ ЗДЕСЬ
  26. #########################################################
  27.  
  28.         preg_match_all('/h3 style="padding-left:10px;">[^>]+>/',$contents,$title);
  29.  
  30.         fwrite ($fp,"$i".substr($title[0][0],30,-5)."\r\n");
  31.  
  32.         fwrite ($fp,'http://tradein.arteks.ru'.substr($links[0][$i],22,-2)."\r\n");
  33.  
  34.         $position = strpos($contents,$tag_in);
  35.         $contents = substr($contents,$position);
  36.  
  37.         $position = strpos($contents,$tag_out);
  38.         $contents = substr($contents,0,$position);
  39.  
  40.         preg_match_all('/td>[^>]+>/',$contents,$contents_temp);
  41.  
  42.         $count_temp = count($contents_temp[0]);
  43.  
  44.         for ($j=0; $j<$count_temp; $j++){
  45.             fwrite ($fp,substr($contents_temp[0][$j],3,-5)."\r\n");
  46.         }
  47.  
  48.         preg_match_all('/a class="grouped_elements" href="[^>]+>/',$contents,$links_temp);
  49.  
  50.         $count_temp2 = count($links_temp[0]);
  51.  
  52.         for ($k=0; $k<$count_temp2; $k++){
  53.             fwrite ($fp,substr($links_temp[0][$k],33,-14)."\r\n");
  54.         }
  55.         fwrite ($fp,"\r\n");
  56.     }
  57. }
  58.  


А скрипт каждый раз загружает, исходный код страницы, а буду спорить весит она немало... Для таких дел есть CURL. Безконца грузить контент сраницы это во первых грузит сервер, во вторых обычно максимальное время исполнения скрипта 30 секунд))))

 

Powered by ExBB FM 1.0 RC1