За последние 24 часа нас посетили 200046 программистов и 2071 робот. Сейчас ищут 1870 программистов ...

preg_match_all и curl

Тема в разделе "PHP для новичков", создана пользователем vodorod, 12 янв 2011.

  1. vodorod

    vodorod Активный пользователь

    С нами с:
    10 янв 2011
    Сообщения:
    217
    Симпатии:
    0
    Есть скрипт:
    Код (Text):
    1.  
    2. <?
    3.  
    4.  $ch = curl_init();  
    5.    $uagent = "Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
    6.  
    7.  curl_setopt($ch, CURLOPT_URL, "http://s4.travian.ru/dorf1.php");  
    8.       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    9.           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    10.       curl_setopt($ch, CURLOPT_HEADER, 0);
    11.       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    12.       curl_setopt($ch, CURLOPT_ENCODING, "");
    13.       curl_setopt($ch, CURLOPT_USERAGENT, $uagent);
    14.       curl_setopt($ch, CURLOPT_TIMEOUT, 120);
    15.       curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    16.       curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    17.       curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
    18.       curl_setopt($ch, CURLOPT_COOKIEFILE,"cookies.txt");
    19.   curl_setopt  ($ch, CURLOPT_HEADER, true);
    20.   curl_setopt($ch, CURLOPT_POST,1);
    21.   curl_setopt($ch, CURLOPT_POSTFIELDS,"name=1234&password=1234&w=&login=1234");
    22.  
    23.  
    24.  $output = curl_exec($ch);  
    25.    
    26.  
    27. curl_close($ch);  
    28.  
    29. $r=preg_match_all('/.*/' ,$output,$ab,PREG_SET_ORDER);
    30. print $an[0];
    31.  
    32. ?>
    Скажите почему preg_match_all не выводит содержимое страницы?
     
  2. Jampire

    Jampire Активный пользователь

    С нами с:
    22 авг 2009
    Сообщения:
    181
    Симпатии:
    0
    Адрес:
    Гомель
    Во-первых, что такое $an, если определен массив $ab?
    Во-вторых, учите функцию preg_match_all() - print_r($ab[0]);.
    В третьих, за хрена тут вообще preg_match_all() ? echo $output;
     
  3. vodorod

    vodorod Активный пользователь

    С нами с:
    10 янв 2011
    Сообщения:
    217
    Симпатии:
    0
    А буквы перепутал! Спасибо, а preg_match_all чтобы сделать выборку данных